change download file name
This commit is contained in:
@ -116,22 +116,17 @@ function Index() {
|
||||
|
||||
function downloadReport(url) {
|
||||
fetch(url)
|
||||
.then(async response => {
|
||||
console.log(response);
|
||||
const filename = response.headers
|
||||
.get("Content-Disposition")
|
||||
console.log(filename)
|
||||
// .split('"')[1];
|
||||
const text = await response.text();
|
||||
//console.log(filename)
|
||||
//console.log(text)
|
||||
//return { filename, text };
|
||||
})
|
||||
.then(responseText => this.download(responseText))
|
||||
.catch(error => {
|
||||
//messageNotification("error", error.message);
|
||||
throw new Error(error.message);
|
||||
.then(response => {
|
||||
console.log(response)
|
||||
const filename = response.headers.get('Content-Disposition').split('filename=')[1];
|
||||
response.blob().then(blob => {
|
||||
let url = window.URL.createObjectURL(blob);
|
||||
let a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// function downloadReport(url) {
|
||||
|
||||
Reference in New Issue
Block a user