typedef HeadersReceivedParam property { Object } header callback HeadersReceivedCallback param { HeadersReceivedParam } res typedef ProgressUpdateParam property { number } progress property { number } totalBytesWritten property { number } totalBytesSent property { number } totalBytesExpectedToWrite property { number } totalBytesExpectedToSend callback ProgressUpdateCallback param { ProgressUpdateParam } res export const NETWORK_TIMEOUT = 60000 ; export const XHR_STATS = { UNSENT : 0 , OPENED : 1 , HEADERS_RECEIVED : 2 , LOADING : 3 , DONE : 4 } ; param { XMLHttpRequest } xhr param { Object } header export const setHeader = ( xhr , header ) => { let headerKey ; for ( headerKey in header ) { xhr . setRequestHeader ( headerKey , header [ headerKey ] ) ; } } ; param { string } url returns { Promise < File > } export const convertObjectUrlToBlob = url => { return new Promise ( ( resolve , reject ) => { const xhr = new XMLHttpRequest ( ) ; xhr . open ( 'GET' , url , true ) ; xhr . responseType = 'blob' ; xhr . onload = function ( ) { if ( this . status === 200 ) { resolve ( this . response ) ; } else { reject ( { status : this . status } ) ; } } ; xhr . send ( ) ; } ) ; } ;