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

225
Views
How to combine multiple binary data into single file?

I am trying to download a file with multiple parts on the server.

1 file => 25 chunks

I am sending a request to the server via Axios and getting a response like this one.

enter image description here

My goal is to send a request for 25 chunks and combine all data into a single file.

My code:- (Getting invalid file)

async function getChunks() {
  let i = 0
  for (const url of urls) {
    try {
      const response = await axios.get(url)
      if (i !== 0) {
        const data = fs.readFileSync(`test.txt`, 'utf8')
        console.log(typeof response.data)
        fs.writeFileSync('test.txt', data + response.data, 'binary')
      } else {
        fs.writeFileSync('test.txt', response.data, 'binary')
      }
      i++
    } catch (error) {
      console.log(`unable to get chunk ${url}`)
    }
  }
}
about 4 years ago · Juan Pablo Isaza
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!