I have an implementation for a file upload api using drag and drop multiple files. I am making a call within the for loop as below
uploadFile(file:any[]) {
file.forEach((file, index)=>{
const formData = new FormData();
formData.append('report_file', file);
this.fileService.uploadFile(this.configurations.uploadUrl, formData)
.subscribe(fileResp=>{
console.log('file', fileResp);
}, error=>{
console.log('error while uploading files', error);
});
});
}
This works while uploading. However, I have a requirement to be able to cancel one of the pending file if needed. so, how do I cancel a particular http request if user is opting to cancel that upload? for the bulk cancel I can do unsubscribe to my observable but in this case I need to make others still be uploading.