1

I just learnt the Web Share API and decided to create a file and share it using the navigator.share(). So I created a files called "sample.txt" by this following code-

const parts = [
  new Blob(['you construct a file...'], {
   type: 'text/plain'
  })
];

const file = new File(parts, 'sample.txt', {
  lastModified: new Date(),
  type: "text/plain"
});

And passed it to the navigator.share function as a property called "files" of an object

if (navigator.share) {
  navigator.share({
    title: "Good",
    files: [file]
  })
}

It worked, I could share it in WhatsApp but the name of the file changes to share409662553725258186628...

How can It be shared using the same navigator.share along with retaining it's original name "sample.txt"

0 Answers0