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

268
Vistas
Use IPFS-JS to download images, and render them in the DOM

I am trying to get IPFS-JS to download images, and display them in the browser. The use-case is serving images off of the IPFS network, and having a browser directly fetch it from IPFS, instead of my servers.

I'm using webpack to compile Typescript to JS and run in the browser, and that all seems fine.

What I have so far is...

import {create} from 'ipfs-core'

let node = await create({});
let stream = node.cat("QmbEaXd4cy5nuCdLNgnprh2U83cwVgtZE4vFTCCwFkKzsp");
let imageData = "";
for await (const chunk of stream) {
   imageData += chunk.toString();
}
let imageBlob = new Blob([await imageData], {type: "image/png"});
let imageURL = URL.createObjectURL(imageBlob);
let imageObject = new Image();
imageObject.src = imageURL;
document.getElementById("browserImg")!.appendChild(imageObject);

But when I run this in the browser, I can see the file getting downloaded, and it does show what looks like a binary PNG file when I do a console.log(imageData); But in the browser window, I get the broken image icon, instead of the image that was downloaded. I'm not sure where the breakage is, as there seems to really be no error thrown.

I appreciate any advice or debugging steps yall might be able to provide

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