From babd7783afe85b790e1c558375d7b5013b2d366f Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Tue, 29 Sep 2020 14:04:03 +0000 Subject: [PATCH] fix: file upload path encoding --- frontend/src/utils/upload.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/frontend/src/utils/upload.js b/frontend/src/utils/upload.js index 54b5669e1d..a43f5787f9 100644 --- a/frontend/src/utils/upload.js +++ b/frontend/src/utils/upload.js @@ -96,31 +96,25 @@ export function scanFiles(dt) { }) } -export function handleFiles(files, path, overwrite = false) { +export function handleFiles(files, base, overwrite = false) { for (let i = 0; i < files.length; i++) { - let file = files[i] - - let filename = (file.fullPath !== undefined) ? file.fullPath : file.name - let filenameEncoded = url.encodeRFC5987ValueChars(filename) - let id = store.state.upload.id + let path = base + let file = files[i] - let itemPath = path + filenameEncoded + if (file.fullPath !== undefined) { + path += url.encodePath(file.fullPath) + } else { + path += url.encodeRFC5987ValueChars(file.name) + } if (file.isDir) { - itemPath = path - let folders = file.fullPath.split("/") - - for (let i = 0; i < folders.length; i++) { - let folder = folders[i] - let folderEncoded = encodeURIComponent(folder) - itemPath += folderEncoded + "/" - } + path += '/' } const item = { id, - path: itemPath, + path, file, overwrite }