I am able to download a file using filesaver however the content I am getting is [object Object], I tried using responseType: "blob" as "blob"/"json" but the response is changing to undefined but not the file content. any suggestions?
getBlobChunk(fileSize: number, userRole: String, inFileName: String, inFilePath: String) {
let chunks = [{}];
const chunkSize = 1024 * 1024 * 20; // 20 MB each chunk
let j = 0;
for (let index = 0; index < fileSize; index += chunkSize + 1) {
chunks[j++] = { startRange: index, endRange: index + chunkSize > fileSize ? fileSize : index + chunkSize };
}
let headers = [];
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
const chunk = chunks[chunkIndex];
// const rangeVal = 'bytes=' + chunk['startRange'] + '-' + chunk['endRange'];
const httpHeaders = new HttpHeaders().append('startrange', chunk['startRange']).append('endrange', chunk['endRange']);
headers.push(
this.httpClient.post(url, {
userrole: userRole,
srcfileName: inFileName,
srcfilePath: inFilePath
}, { headers: httpHeaders,responseType: 'blob' as 'blob', reportProgress: true, observe: 'events' })
.pipe(
map((event: any) => {
if (event.type === HttpEventType.DownloadProgress) {
some code...
}
})
)
);
}
return forkJoin(headers);
}
note: I can see the file content under response tab
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…