From 754640d552db0f2e49e69da0918c555159f0e38e Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 20 Jun 2019 09:23:55 +0200 Subject: [PATCH] uploadfile options fix --- back/methods/dms/uploadFile.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/back/methods/dms/uploadFile.js b/back/methods/dms/uploadFile.js index 3091f7184..2d4cc94da 100644 --- a/back/methods/dms/uploadFile.js +++ b/back/methods/dms/uploadFile.js @@ -42,20 +42,21 @@ module.exports = Self => { } }); - Self.uploadFile = async(ctx, options = {}) => { + Self.uploadFile = async(ctx, options) => { const storageConnector = Self.app.dataSources.storage.connector; const models = Self.app.models; const fileOptions = {}; const args = ctx.args; let tx; + let myOptions = {}; if (typeof options == 'object') - Object.assign(options, options); + Object.assign(myOptions, options); - if (!options.transaction) { + if (!myOptions.transaction) { tx = await Self.beginTransaction({}); - options.transaction = tx; + myOptions.transaction = tx; } try { @@ -72,7 +73,7 @@ module.exports = Self => { const addedDms = []; for (const file of files) { - const newDms = await createDms(ctx, file.name, options); + const newDms = await createDms(ctx, file.name, myOptions); const pathHash = storageConnector.getPathHash(newDms.id); const container = await getContainer(pathHash); @@ -92,7 +93,7 @@ module.exports = Self => { } }; - async function createDms(ctx, fileName, options) { + async function createDms(ctx, fileName, myOptions) { const models = Self.app.models; const storageConnector = Self.app.dataSources.storage.connector; const myUserId = ctx.req.accessToken.userId; @@ -107,12 +108,12 @@ module.exports = Self => { reference: args.reference, description: args.description, hasFile: args.hasFile - }, options); + }, myOptions); const extension = storageConnector.getFileExtension(fileName); fileName = `${newDms.id}.${extension}`; - return newDms.updateAttribute('file', fileName, options); + return newDms.updateAttribute('file', fileName, myOptions); }