Created
June 16, 2020 03:45
-
-
Save railsstudent/3cbe8b6b97c185b46621ab64937e74bd to your computer and use it in GitHub Desktop.
use file-saver to open file
This file contains hidden or 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
// private getFileNameFromContentDisposition(res: FileDownloadResponse<Blob>) { | |
// const { contentDisposition } = res; | |
// const matches = /filename=([^;]+)/gi.exec(contentDisposition); | |
// const tempFilename = ((matches && matches[1]) || 'untitled').trim(); | |
// const filename = tempFilename.replace(/["]/g, ''); | |
// return filename; | |
// } | |
// static openFile(response: FileDownloadResponse<Blob>) { | |
// if (response && response.body) { | |
// const { contentType } = response; | |
// const filename = FileDownloadHelper.getFileNameFromContentDisposition(response); | |
// saveAs(new Blob([response.body], { type: contentType }), filename); | |
// } | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment