Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

178
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda