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

166
Views
Reaccionar javascript: toDataURL genera una URL de datos vacía debido a un error al obtener la imagen como archivo

Este es mi código:

 fetch(profilePictureURL, { mode: "no-cors" }) .then(function (res) { return res.arrayBuffer(); }) .then(function (buf) { var file = new File([buf], "new.png", { type: "image/png" }); console.log(file); const reader = new FileReader(); reader.readAsDataURL(file); reader.addEventListener("load", () => { console.log(reader.result); uploadBytes(storageProfileBusinessRef, file); }); });

console.log(reader.result) proporciona data: .

Mientras que, console.log(file) da salida:

 File {name: 'new.png', lastModified: 1657861829861, lastModifiedDate: Fri Jul 15 2022 10:40:29 GMT+0530 (India Standard Time), webkitRelativePath: '', size: 0, …} lastModified: 1657861829861 lastModifiedDate: Fri Jul 15 2022 10:40:29 GMT+0530 (India Standard Time) {} name: "new.png" size: 0 type: "image/png" webkitRelativePath: "" [[Prototype]]: File

De la salida anterior parece que el tamaño del archivo es 0. Para eso hice, console.log(buf) , extrañamente tenía una salida ArrayBuffer(0) .

Pero he verificado que la URL de la imagen está perfectamente bien. ¿Cuál podría ser el error aquí?

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