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

179
Vistas
Getting blank png file from share api

I have a js web app that creates an image based on user selected components.

The canvas is converted to base64 data earlier in the code.

I want to be able to share the finished image via the Web Share Api but I seem to be hitting a snag.

The app seems to be producing a png file but its blank, however, using the same variable (pngUrl) in a download function appears to work just fine.

d_canvas.href = pngUrl;
d_canvas.download = "Alien_"+(Date.now())+".png";
d_canvas.click(); 

Hoping someone can help me figure out what I am missing.

I am running into issues with the following code:

async function Share(){
  var pngUrl = to_base64();
const blob = fetch(pngUrl).then(res => res.blob()).then(blob => console.log(blob));
const filesArray = [
  new File(
    [blob],
    "Alien_"+(Date.now())+".png",
    {
      type: blob.type,
      lastModified: new Date().getTime()
    }
  )
];
const shareData = {
  files: filesArray,
};
try {
  if (!(navigator.canShare(shareData))) {
    throw new Error('Can\'t share data.', shareData);
  };
  await navigator.share(shareData);
} catch (err) {
  console.error(err.name, err.message);
}
}
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