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

134
Vistas
Passing file Blob as a prop to a react component causes loss of data

I have a simple file chunking system to upload data to a server via many chunks, to do this I delegate the splitting and uploadin task to a dedicated component... However when passing the received Blob, from user, to my dedicated component, the prop in that component doesn't seem to contain anything... Indeed the Blob slice() method throws an error complaining it is an illegal action to slice an empty blob... Also calling .text() on the blob object gives an empty string.

Here a simplified version:

const Uploader = ({ fileBlob }) => {
     
     useEffect(() => {
          fileBlob.text().then(textContent => console.log(textContent)); // Logs an empty string
          let chunk = fileBlob.slice(0, fileBlob.size() / 2); // Throws
     });

     return (<some stuff />)
}

const BlobFromUser = () => {
    const fileUpload = (fileBlob) => {
         fileBlob.text().then(textContent => console.log(textContent)); // Logs the actual content

         notify(<Uploader fileBlob={fileBlob} />);
    }

    return (<file upload user form triggers fileUpload()/>)
}

Also, reading .size() from Uploader yields the expected size, but the blob doesn't contain anything.

about 4 years ago · Santiago Trujillo
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