Fix Download Blob Pdf
This commit is contained in:
@@ -358,15 +358,25 @@ export default function CorporatePlanList() {
|
||||
|
||||
const handleDownloadLog = (row: ReturnType<typeof createData>) => {
|
||||
setLoadingLog(true);
|
||||
axios.get(`generate-log/${row.id}`)
|
||||
axios.get(`generate-log/${row.id}`, {
|
||||
responseType: 'blob'
|
||||
})
|
||||
.then((response) => {
|
||||
const link = document.createElement('a');
|
||||
link.href = response.data.data.file_url;
|
||||
link.setAttribute('download', response.data.data.file_name);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
window.open(URL.createObjectURL(response.data));
|
||||
// const content = response.headers['content-type'];
|
||||
// download(response.data, file.file_name, content);
|
||||
// const link = document.createElement('a');
|
||||
// console.log(response.data);
|
||||
// link.href = response.data.data.file_url;
|
||||
// link.setAttribute('download', response.data.data.file_name);
|
||||
// document.body.appendChild(link);
|
||||
// link.click();
|
||||
setLoadingLog(false);
|
||||
})
|
||||
// .then((blobFile) => {
|
||||
// new File([blobFile], 'asdads.pdf', { type: blobFile.type })
|
||||
// setLoadingLog(false);
|
||||
// })
|
||||
.catch((response) => {
|
||||
enqueueSnackbar(response.message, {variant: 'error'})
|
||||
setLoadingLog(false);
|
||||
|
||||
Reference in New Issue
Block a user