diff --git a/src/lib/rx-file-upload.ts b/src/lib/rx-file-upload.ts index da00584..af01c83 100644 --- a/src/lib/rx-file-upload.ts +++ b/src/lib/rx-file-upload.ts @@ -18,6 +18,7 @@ import { RxFileUploadAdditionalFormData, RxFileUploadBodyData, RxFileUploadChunkBodyData, + RxFileUploadChunkData, RxFileUploadChunkFormData, RxFileUploadChunkSequenceData, RxFileUploadChunkSize, @@ -126,6 +127,13 @@ export class RxFileUploadCls implements RxFileUpload { * @internal */ private readonly _useChunks: boolean = false; + /** + * Property to store default mime type for a chunk + * + * @private + * @internal + */ + private readonly _chunkMimeType: string = 'application/octet-stream'; /** * Property to store flag to know if progress Observable will complete at the end of the upload process * @@ -691,15 +699,22 @@ export class RxFileUploadCls implements RxFileUpload { data: { ...fileData, chunkData: this._serialize({ + name: `${file.name}.part${index + 1}`, + size: _.endByte - _.startByte, + lastModified: file.lastModified, + type: this._chunkMimeType, sequence: index + 1, totalChunks: chunkSizes.length, startByte: _.startByte, endByte: _.endByte, - }), + } as RxFileUploadChunkData), file: new File( [file.slice(_.startByte, _.endByte)], - file.name, - { type: file.type }, + `${file.name}.part${index + 1}`, + { + type: this._chunkMimeType, + lastModified: file.lastModified, + }, ), }, formData: new FormData(), diff --git a/src/lib/types.ts b/src/lib/types.ts index e0d319e..1762477 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -148,3 +148,18 @@ export type RxFileUploadFileData = { type: string; sha256Checksum?: string; }; + +/** + * ChunkData type definition + * + * @internal + */ +export type RxFileUploadChunkData = Omit< + RxFileUploadFileData, + 'sha256Checksum' +> & { + sequence: number; + totalChunks: number; + startByte: number; + endByte: number; +};