export class FileUtilities { private static readonly binaryExtensions = [ '.zip' , '.exe' , '.dll' , '.png' , '.jpeg' , '.jpg' , '.gif' , '.bmp' , '.ico' , '.pdf' , '.so' , '.ttf' , '.bz2' , '.gz' , '.jar' , '.cab' , '.tar' , '.iso' , '.img' , '.dmg' , ] ; public static isBinary ( fileName ) { return ! ! fileName && FileUtilities . binaryExtensions . some ( e => fileName . toLowerCase ( ) . endsWith ( e ) ) ; } public static saveFile ( blob , fileName ) { const windowUrl = window . URL || ( < any > window ) . webkitURL ; if ( window . navigator . msSaveOrOpenBlob ) { window . navigator . msSaveOrOpenBlob ( blob , fileName ) ; } else { const anchor = document . createElement ( 'a' ) ; anchor . style . display = 'none' ; document . body . appendChild ( anchor ) ; setTimeout ( ( ) => { const url = windowUrl . createObjectURL ( blob ) ; anchor . href = url ; anchor . download = fileName ; anchor . click ( ) ; window . URL . revokeObjectURL ( url ) ; } ) ; } } }