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

177
Views
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
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!