更新文件名字
This commit is contained in:
parent
576b5807c3
commit
e9cedbe908
@ -1,4 +1,7 @@
|
||||
export const downloadFile=(fileUrl,name='')=>{
|
||||
let startIndex=fileUrl.indexOf("output");
|
||||
let endIndex=fileUrl.lastIndexOf(".");
|
||||
let originName=fileUrl.substring(startIndex,endIndex);
|
||||
const request = new XMLHttpRequest()
|
||||
request.open('GET', fileUrl)
|
||||
request.responseType = 'blob'
|
||||
@ -6,8 +9,8 @@ export const downloadFile=(fileUrl,name='')=>{
|
||||
if (res.target.status == 200) {
|
||||
const url = window.URL.createObjectURL(res.currentTarget.response)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.setAttribute('download', name+new Date().getTime())
|
||||
link.href = url;
|
||||
link.setAttribute('download',originName)
|
||||
link.click()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user