diff --git a/src/api/system-boot/file.ts b/src/api/system-boot/file.ts index 5be9ad94..eae81f1b 100644 --- a/src/api/system-boot/file.ts +++ b/src/api/system-boot/file.ts @@ -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',