正则替换[]
This commit is contained in:
@@ -7,8 +7,20 @@ const SYSTEM_PREFIX = '/system-boot'
|
||||
* @param file
|
||||
*/
|
||||
export const uploadFile = (file: any, path: string) => {
|
||||
const regex = /\[|\]/g
|
||||
// 替换规则:[ 换成 (,] 换成 )
|
||||
|
||||
const newFile = new File(
|
||||
[file], // 原文件的二进制内容
|
||||
file.name.replace(regex, match => (match === '[' ? '(' : ')')), // 新的文件名
|
||||
{
|
||||
type: file.type, // 复用原文件的MIME类型
|
||||
lastModified: file.lastModified // 复用最后修改时间
|
||||
}
|
||||
)
|
||||
|
||||
let form = new FormData()
|
||||
form.append('file', file)
|
||||
form.append('file', newFile)
|
||||
form.append('path', path)
|
||||
return createAxios({
|
||||
url: SYSTEM_PREFIX + '/file/upload',
|
||||
|
||||
Reference in New Issue
Block a user