Created
February 4, 2021 23:11
-
-
Save yoandresaav/228c274a359f457088ad84fcbe5193f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const downloadCVs = async () => { | |
const url = window.django.urls.get_documens_cvs_for_have_company_whitout_member; | |
const response = await axios.get(url, {params: { applicant: applicant.id }, responseType: 'arraybuffer'}); | |
let fileName = response.headers["content-disposition"].split("filename=")[1]; | |
if (window.navigator && window.navigator.msSaveOrOpenBlob) { // IE variant | |
window.navigator.msSaveOrOpenBlob(new Blob([response.data], {type: 'application/zip'}), | |
fileName); | |
} else { | |
const blob = new Blob([response.data], {type: 'application/zip'}); | |
const url = URL.createObjectURL(blob); | |
const link = document.createElement('a'); | |
link.href = url; | |
link.setAttribute('download', response.headers["content-disposition"].split("filename=")[1]); | |
document.body.appendChild(link); | |
link.click(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment