import { Injectable } from '@angular/core' ; import { CHUNK_SIZE } from '../config' ; export interface Chunk { file : Blob ; } @ Injectable ( { providedIn : 'root' , } ) export class FileChunkService { SIZE : number = CHUNK_SIZE ; file : Blob ; constructor ( ) { } param file param size createFileChunk ( file , size = this . SIZE ) { const fileChunkList = [ ] ; let cur = 0 ; while ( cur < file . size ) { fileChunkList . push ( { file : file . slice ( cur , cur + size ) } ) ; cur += size ; } return fileChunkList ; } param file handleFile ( file ) { return new Promise ( reject => { this . file = file ; let fileChunkList = this . createFileChunk ( this . file ) ; reject ( fileChunkList ) ; } ) ; } }