Merge pull request #8429 from Budibase/fix/gzip-import
Fixing server to handle both gzip and x-gzip mimetypes for app imports
This commit is contained in:
commit
24f26dd2bc
|
@ -120,6 +120,9 @@ async function updateAutomations(prodAppId: string, db: PouchDB.Database) {
|
||||||
* @returns {Object} Returns a fs read stream which can be loaded into the database.
|
* @returns {Object} Returns a fs read stream which can be loaded into the database.
|
||||||
*/
|
*/
|
||||||
async function getTemplateStream(template: TemplateType) {
|
async function getTemplateStream(template: TemplateType) {
|
||||||
|
if (template.file && template.file.type !== "text/plain") {
|
||||||
|
throw new Error("Cannot import a non-text based file.")
|
||||||
|
}
|
||||||
if (template.file) {
|
if (template.file) {
|
||||||
return fs.createReadStream(template.file.path)
|
return fs.createReadStream(template.file.path)
|
||||||
} else if (template.key) {
|
} else if (template.key) {
|
||||||
|
@ -156,7 +159,7 @@ export async function importApp(
|
||||||
) {
|
) {
|
||||||
let prodAppId = dbCore.getProdAppID(appId)
|
let prodAppId = dbCore.getProdAppID(appId)
|
||||||
let dbStream: any
|
let dbStream: any
|
||||||
const isTar = template.file && template.file.type === "application/gzip"
|
const isTar = template.file && template?.file?.type?.endsWith("gzip")
|
||||||
const isDirectory =
|
const isDirectory =
|
||||||
template.file && fs.lstatSync(template.file.path).isDirectory()
|
template.file && fs.lstatSync(template.file.path).isDirectory()
|
||||||
if (template.file && (isTar || isDirectory)) {
|
if (template.file && (isTar || isDirectory)) {
|
||||||
|
|
Loading…
Reference in New Issue