🐛fix(*): 修复文件名有特殊字符时上传失败的问题

This commit is contained in:
jmal 2021-05-02 09:00:32 +08:00
parent 3515ae6b5f
commit 7f29ea6dd3
2 changed files with 5 additions and 5 deletions

View File

@ -347,8 +347,8 @@
// 文件状态设为“合并中” // 文件状态设为“合并中”
this.statusSet(file.id, 'merging') this.statusSet(file.id, 'merging')
api.mergeSimpleUpload({ api.mergeSimpleUpload({
filename: file.name, filename: encodeURIComponent(file.name),
relativePath: file.relativePath, relativePath: encodeURIComponent(file.relativePath),
identifier: file.uniqueIdentifier, identifier: file.uniqueIdentifier,
currentDirectory: this.params.currentDirectory, currentDirectory: this.params.currentDirectory,
username: this.params.username, username: this.params.username,

View File

@ -10,9 +10,9 @@ export default {
// 预览文件的url // 预览文件的url
previewUrl: function(username, file, token) { previewUrl: function(username, file, token) {
if (token) { if (token) {
return `${this.baseUrl}/file/${username}${file.path}${file.name}?jmal-token=${token}` return `${this.baseUrl}/file/${username}${file.path}${encodeURIComponent(file.name)}?jmal-token=${token}`
} else { } else {
return `${this.baseUrl}/file/${username}${file.path}${file.name}` return `${this.baseUrl}/file/${username}${file.path}${encodeURIComponent(file.name)}`
} }
}, },
// mardown里上传图片后的图片预览地址 // mardown里上传图片后的图片预览地址
@ -27,7 +27,7 @@ export default {
// 下载文件 // 下载文件
download: function(username, file, token) { download: function(username, file, token) {
fileApi.isAllowDownload().then(() => { fileApi.isAllowDownload().then(() => {
let url = `${this.baseUrl}/file/${username}${file.path}${file.name}?jmal-token=${token}&o=download` let url = `${this.baseUrl}/file/${username}${file.path}${encodeURIComponent(file.name)}?jmal-token=${token}&o=download`
window.open(url, '_self') window.open(url, '_self')
}) })
}, },