正则替换[]

This commit is contained in:
guanj
2026-01-04 09:01:32 +08:00
parent 72b1f39814
commit 2a11891988

View File

@@ -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',