Skip to content

Commit

Permalink
fix: file upload path encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiresviana committed Sep 29, 2020
1 parent 1529e79 commit babd778
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions frontend/src/utils/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit babd778

Please sign in to comment.