fix: file upload path encoding
parent
1529e796df
commit
babd7783af
|
@ -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++) {
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
let id = store.state.upload.id
|
||||||
|
let path = base
|
||||||
let file = files[i]
|
let file = files[i]
|
||||||
|
|
||||||
let filename = (file.fullPath !== undefined) ? file.fullPath : file.name
|
if (file.fullPath !== undefined) {
|
||||||
let filenameEncoded = url.encodeRFC5987ValueChars(filename)
|
path += url.encodePath(file.fullPath)
|
||||||
|
} else {
|
||||||
let id = store.state.upload.id
|
path += url.encodeRFC5987ValueChars(file.name)
|
||||||
|
}
|
||||||
let itemPath = path + filenameEncoded
|
|
||||||
|
|
||||||
if (file.isDir) {
|
if (file.isDir) {
|
||||||
itemPath = path
|
path += '/'
|
||||||
let folders = file.fullPath.split("/")
|
|
||||||
|
|
||||||
for (let i = 0; i < folders.length; i++) {
|
|
||||||
let folder = folders[i]
|
|
||||||
let folderEncoded = encodeURIComponent(folder)
|
|
||||||
itemPath += folderEncoded + "/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const item = {
|
const item = {
|
||||||
id,
|
id,
|
||||||
path: itemPath,
|
path,
|
||||||
file,
|
file,
|
||||||
overwrite
|
overwrite
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue