feat(file): 下载404(待解决)
This commit is contained in:
parent
c7f5936a5b
commit
e94c50a543
@ -15,9 +15,9 @@ export function uploadFile(file) {
|
||||
|
||||
// 文件下载接口(需要处理二进制流)
|
||||
export function downloadFile(fileId) {
|
||||
return axiosInstance.get(`/file/files/${fileId}`, {
|
||||
responseType: 'blob', // 指定响应类型为二进制流
|
||||
timeout: 15000 // 下载超时时间延长至15秒
|
||||
return get(`/file/files/${fileId}`, {
|
||||
// responseType: 'blob', // 指定响应类型为二进制流
|
||||
// timeout: 15000 // 下载超时时间延长至15秒
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -154,6 +154,11 @@ const beforeUpload = async file => {
|
||||
const handleDownload = async record => {
|
||||
try {
|
||||
const response = await downloadFile(record._id)
|
||||
console.log(response)
|
||||
if(response.code === -1) {
|
||||
message.error('下载失败,文件不存在')
|
||||
return
|
||||
}
|
||||
const url = window.URL.createObjectURL(new Blob([response]))
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
|
Loading…
x
Reference in New Issue
Block a user