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