|
|
@@ -58,17 +58,21 @@ export const postWithFiles = ({url, params, files, onSuccess, onFail, onError}) |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
export const fileDownload = ({fileId, skey, filename, onResponse, onError}) =>{ |
|
|
|
axios.get( FILE_DOWN_GET+"/"+fileId+"/"+skey+"/"+filename, |
|
|
|
export const fileDownload = ({url, fileId, skey, filename, onResponse, onError}) =>{ |
|
|
|
if(!url){ |
|
|
|
url = FILE_DOWN_GET+"/"+fileId+"/"+skey+"/"+filename |
|
|
|
} |
|
|
|
axios.get( url, |
|
|
|
{ |
|
|
|
responseType: 'blob', |
|
|
|
} |
|
|
|
).then( |
|
|
|
(response)=>{ |
|
|
|
const fn = response.headers.get("content-disposition")?.split("filename=")[1]?.split('"')[1]?.trim()??filename; |
|
|
|
const url = URL.createObjectURL(response.data); |
|
|
|
const a = document.createElement('a'); |
|
|
|
a.href = url; |
|
|
|
a.setAttribute("download", filename); |
|
|
|
a.setAttribute("download", fn); |
|
|
|
document.body.appendChild(a); |
|
|
|
a.click(); |
|
|
|
document.body.removeChild(a); |
|
|
@@ -82,30 +86,30 @@ export const fileDownload = ({fileId, skey, filename, onResponse, onError}) =>{ |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
export const reportDownload = ({url, onError}) =>{ |
|
|
|
axios.get( url, |
|
|
|
{ |
|
|
|
responseType: 'blob', |
|
|
|
} |
|
|
|
).then( |
|
|
|
(response)=>{ |
|
|
|
const filename = response.headers |
|
|
|
.get("content-disposition") |
|
|
|
.split("filename=")[1] |
|
|
|
.split('"')[1].trim(); |
|
|
|
const url = URL.createObjectURL(response.data); |
|
|
|
const a = document.createElement('a'); |
|
|
|
a.href = url; |
|
|
|
a.setAttribute("download", filename); |
|
|
|
document.body.appendChild(a); |
|
|
|
a.click(); |
|
|
|
document.body.removeChild(a); |
|
|
|
URL.revokeObjectURL(url); |
|
|
|
} |
|
|
|
).catch(error => { |
|
|
|
return handleError(error,onError); |
|
|
|
}); |
|
|
|
}; |
|
|
|
// export const reportDownload = ({url, onError}) =>{ |
|
|
|
// axios.get( url, |
|
|
|
// { |
|
|
|
// responseType: 'blob', |
|
|
|
// } |
|
|
|
// ).then( |
|
|
|
// (response)=>{ |
|
|
|
// const filename = response.headers |
|
|
|
// .get("content-disposition") |
|
|
|
// .split("filename=")[1] |
|
|
|
// .split('"')[1].trim(); |
|
|
|
// const url = URL.createObjectURL(response.data); |
|
|
|
// const a = document.createElement('a'); |
|
|
|
// a.href = url; |
|
|
|
// a.setAttribute("download", filename); |
|
|
|
// document.body.appendChild(a); |
|
|
|
// a.click(); |
|
|
|
// document.body.removeChild(a); |
|
|
|
// URL.revokeObjectURL(url); |
|
|
|
// } |
|
|
|
// ).catch(error => { |
|
|
|
// return handleError(error,onError); |
|
|
|
// }); |
|
|
|
// }; |
|
|
|
|
|
|
|
export const fileUpload = ({ refType, refId, files, refCode, onSuccess, onFail, onError}) =>{ |
|
|
|
// console.log(files); |
|
|
|