|
|
|
@ -28,14 +28,22 @@ export function uploadedFilesList(query) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 新增
|
|
|
|
// 新增
|
|
|
|
export function add(data) { |
|
|
|
export function add(file) { |
|
|
|
|
|
|
|
const formData = new FormData(); |
|
|
|
|
|
|
|
// 确保使用'file'作为字段名,这是后端要求的
|
|
|
|
|
|
|
|
formData.append('file', file); |
|
|
|
return request({ |
|
|
|
return request({ |
|
|
|
url: api + '/upload', |
|
|
|
url: api + '/upload', |
|
|
|
method: 'get', |
|
|
|
method: 'post', |
|
|
|
data: data, |
|
|
|
data: formData, |
|
|
|
|
|
|
|
// 当使用FormData时,让浏览器自动设置Content-Type
|
|
|
|
headers: { |
|
|
|
headers: { |
|
|
|
'Content-Type': 'multipart/form-data' |
|
|
|
'Content-Type': 'multipart/form-data' |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 处理二进制数据
|
|
|
|
|
|
|
|
transformRequest: [function(data) { |
|
|
|
|
|
|
|
return data; |
|
|
|
|
|
|
|
}] |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|