0

On mobile phone I want to provide image share using Javascript navigate.share() method

This interface requires a list of files for attachment as explained here

In the share files example, the interface requires the user to select a file, however, the image I want to share resides in a buffer (large string).

How can I share that buffer as a file?

DarkBee
  • 16,592
  • 6
  • 46
  • 58

1 Answers1

0

You can convert your buffer to string by doing

var myString = myBuffer.toString();

Then converting it to blob

var blob = new Blob([myString], { type: 'text/plain' });

And finally to file

var file = new File([blob], "myFile.jpg", {type: "image/jpeg"});
Daxelarne
  • 172
  • 11