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

267
Vistas
How to transfer file chunks for large file download and reconstruct it in javascript?

I need to download large files using files chunks for which JAVA spring server is developed and files are recived at UI via REST api. Looking for solution to join all chunks in javascript

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

i am not sure about your requirement but hope this will help you

first you need to fetch the file using a fetch call inside a async function

response = await fetch(url);

then after that you will be able to get a reader from the response const reader = response.body.getReader();

you can track the fetch by measuring the progress for that store the total file size

const contentLength = +response.headers.get('Content-Length');

in ordre to track the recieved bytes let receivedLength = 0;

to store the chunks recieved

let chunks = []; // array of received binary chunks (comprises the body)

after that do a while loop which will run endlessly

while(true) {
          const {done, value} = await reader.read();

          if (done) {
            break;
          }

          chunks.push(value);
          receivedLength += value.length;
            
          let compleated = Math.round(receivedLength/contentLength*100);

          console.log(`Received ${receivedLength} of ${contentLength}`)
        }

 after the while loop has broken you can check if the transfer is fully completed or not

then you can create a blob from the array which we stored our chunks of data

let blob = new Blob(chunks);

then you can use this blob

about 4 years ago · Juan Pablo Isaza Denunciar
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