I am currently working on implementing a file upload feature in Angular. I have tackled the issue of file size restrictions by creating an API endpoint that can receive file chunks. Once all the chunks are received, another endpoint needs to be triggered to combine these chunks on the server. The challenge I am facing is determining when all the post requests are complete without relying on Promises. Since I am new to Angular and JavaScript, I am unsure how to approach this problem.
let i = 0;
for(let offset = 0; offset < file.size; offset += chunkSize) {
let chunk = file.slice( offset, offset + chunkSize );
let formData = new FormData();
formData.append("fileUpload", chunk, file.name + ".part" + i);
formData.append("identifier", identifier.toString());
this.http.post(this.baseUrl + "Upload", formData).subscribe();
}