import { Uploader } from 'ngx-uploadx' ; /**
 * Implements nginx-upload-module resumable uploads protocol.
 *
 *  https example export class NginxUploadModuleUploader extends Uploader { offset = 0 ; response = '' ; async getFileUrl ( ) { return this . endpoint ; } async getOffset ( ) { return this . offset ; } async sendFileContent ( ) { const { body , end } = this . getChunk ( ) ; const headers = { 'Content-Type' : this . file . type , 'Session-ID' : `${ this . uploadId }` , 'Content-Disposition' : `attachment; filename="${ encodeURIComponent ( this . name ) }"` , 'Content-Range' : `bytes ${ this . offset }-${ end - 1 }/${ this . size }` } ; await this . request ( { method : 'POST' , body , url : this . url , headers } ) ; return this . getOffsetFromResponse ( ) ; } abort ( ) { } private getOffsetFromResponse ( ) { if ( this . response && this . responseStatus === 201 ) { const [ , end ] = this . response . split ( /\D+/ ) . filter ( ( v ) => v . length ) . map ( Number ) . reverse ( ) ; if ( isNaN ( end ) ) { throw new Error ( 'Range is missing!' ) ; } this . offset = end + 1 ; return this . offset ; } else if ( this . responseStatus === 200 ) { return this . size ; } return this . offset ; } }