import { saveAs } from 'file-saver' ; import { Response } from '@angular/http' ; param blobContent param fileName export const saveFile = ( blobContent , fileName ) => { fileName = fileName . replace ( /^"(.*)"$/ , '$1' ) ; const blob = new Blob ( [ blobContent ] , { type : 'application/octet-stream' } ) ; saveAs ( blob , fileName ) ; } ; param res export const getFileNameFromResponseContentDisposition = ( res ) => { const contentDisposition = res . headers . get ( 'content-disposition' ) || '' ; const matches = /filename=([^;]+)/ig . exec ( contentDisposition ) ; const fileName = ( matches [ 1 ] || 'untitled' ) . trim ( ) ; return fileName ; } ;