Skip to content

Commit babd778

Browse files
committed
fix: file upload path encoding
1 parent 1529e79 commit babd778

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

frontend/src/utils/upload.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,25 @@ export function scanFiles(dt) {
9696
})
9797
}
9898

99-
export function handleFiles(files, path, overwrite = false) {
99+
export function handleFiles(files, base, overwrite = false) {
100100
for (let i = 0; i < files.length; i++) {
101-
let file = files[i]
102-
103-
let filename = (file.fullPath !== undefined) ? file.fullPath : file.name
104-
let filenameEncoded = url.encodeRFC5987ValueChars(filename)
105-
106101
let id = store.state.upload.id
102+
let path = base
103+
let file = files[i]
107104

108-
let itemPath = path + filenameEncoded
105+
if (file.fullPath !== undefined) {
106+
path += url.encodePath(file.fullPath)
107+
} else {
108+
path += url.encodeRFC5987ValueChars(file.name)
109+
}
109110

110111
if (file.isDir) {
111-
itemPath = path
112-
let folders = file.fullPath.split("/")
113-
114-
for (let i = 0; i < folders.length; i++) {
115-
let folder = folders[i]
116-
let folderEncoded = encodeURIComponent(folder)
117-
itemPath += folderEncoded + "/"
118-
}
112+
path += '/'
119113
}
120114

121115
const item = {
122116
id,
123-
path: itemPath,
117+
path,
124118
file,
125119
overwrite
126120
}

0 commit comments

Comments
 (0)