Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
Waiting for post requests to finish

I'm trying to implement a file upload in Angular. To avoid file size restrictions, I implemented an API endpoint that receives chunks of a file. After all chunks are received another endpoint should be called that reassembles the chunks on the server. Therefor I need to know when all post requests are finished. Preferably without using Promises. The problem is, I'm new to Angular (and even JS) so I'm wondering how this can work.

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();
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You put these into an array and utilize forkJoin and then subscribe to that.

This will call all the http requests at one time, and the subscribe function will be called once all of them are complete.

let i = 0;
const obsArray = [];
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());
    obsArray.push(
      this.http.post(this.baseUrl + "Upload", formData)
    ).
}
forkJoin(obsArray).subscribe();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!