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

231
Views
¿Hay alguna forma de generar una URL para una imagen cargada?

Estuve trabajando en un componente en el que cuando cargamos una imagen desde el escritorio, inicialmente creó una URL de objeto usando URL.createObjectURL(). Pero, recientemente leí en alguna parte que createObjectURL está obsoleto para MediaStream. Además, estaba recibiendo este error:

"Error al ejecutar 'createObjectURL' en 'URL': error en la resolución de sobrecarga".

También supe que podíamos configurar el srcObject en MediaStream y eso funcionaría. Pero, para la carga de imágenes, no funcionaba. ¿Hay alguna forma en la que pueda crear la URL temporal y configurar el src de la etiqueta img para que pueda obtener una vista previa en la página web? Cualquier ayuda es apreciada, ¡Gracias!

Aquí está el código que estaba usando anteriormente

 const el = profilePicture.current; const myMemoObj = URL.createObjectURL(event.target.files[0]); el.src = URL.createObjectURL(event.target.files[0]); URL.revokeObjectURL(myMemoObj);

También intenté configurar el.srcObject en event.target.files[0] pero no funcionó.

Editar: profilePicture es una referencia adjunta a una etiqueta img en el mismo componente

 profilePicture = useRef(null); . . . <img ref={profilePicture} alt="Profile Picture"/>
about 4 years ago · Juan Pablo Isaza
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!