Skip to content

Commit 8d703ac

Browse files
committed
feat(rxFileUpload): add new fields in chunkData + update File instance for chunk binary with the same values than chunkData
1 parent ede886e commit 8d703ac

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

src/lib/rx-file-upload.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
RxFileUploadAdditionalFormData,
1919
RxFileUploadBodyData,
2020
RxFileUploadChunkBodyData,
21+
RxFileUploadChunkData,
2122
RxFileUploadChunkFormData,
2223
RxFileUploadChunkSequenceData,
2324
RxFileUploadChunkSize,
@@ -126,6 +127,13 @@ export class RxFileUploadCls implements RxFileUpload {
126127
* @internal
127128
*/
128129
private readonly _useChunks: boolean = false;
130+
/**
131+
* Property to store default mime type for a chunk
132+
*
133+
* @private
134+
* @internal
135+
*/
136+
private readonly _chunkMimeType: string = 'application/octet-stream';
129137
/**
130138
* Property to store flag to know if progress Observable will complete at the end of the upload process
131139
*
@@ -691,15 +699,22 @@ export class RxFileUploadCls implements RxFileUpload {
691699
data: {
692700
...fileData,
693701
chunkData: this._serialize({
702+
name: `${file.name}.part${index + 1}`,
703+
size: _.endByte - _.startByte,
704+
lastModified: file.lastModified,
705+
type: this._chunkMimeType,
694706
sequence: index + 1,
695707
totalChunks: chunkSizes.length,
696708
startByte: _.startByte,
697709
endByte: _.endByte,
698-
}),
710+
} as RxFileUploadChunkData),
699711
file: new File(
700712
[file.slice(_.startByte, _.endByte)],
701-
file.name,
702-
{ type: file.type },
713+
`${file.name}.part${index + 1}`,
714+
{
715+
type: this._chunkMimeType,
716+
lastModified: file.lastModified,
717+
},
703718
),
704719
},
705720
formData: new FormData(),

src/lib/types.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,18 @@ export type RxFileUploadFileData = {
148148
type: string;
149149
sha256Checksum?: string;
150150
};
151+
152+
/**
153+
* ChunkData type definition
154+
*
155+
* @internal
156+
*/
157+
export type RxFileUploadChunkData = Omit<
158+
RxFileUploadFileData,
159+
'sha256Checksum'
160+
> & {
161+
sequence: number;
162+
totalChunks: number;
163+
startByte: number;
164+
endByte: number;
165+
};

0 commit comments

Comments
 (0)