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

132
Views
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
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!