Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

218
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda