-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
We are developing a dApp using metamask browser extension and we also want to able to use it on metamask mobile browser.
We need to download files on the client-side.
On the desktop the download of the files are working well:
function createDownloadLink(file: File): void {
const objectURL = URL.createObjectURL(file);
const link = document.createElement('a');
link.setAttribute('href', objectURL);
link.setAttribute('download', file.name as string);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(objectURL);
}
BUT in Metamask mobile just crashes and exits when we click on the download.
We also to refactor to use FileReader instead of URL API (https://developer.mozilla.org/pt-BR/docs/Web/API/FileReader/FileReader) but it still crashes.
Other approaches that we tried was https://www.npmjs.com/package/file-saver and https://github.com/jimmywarting/StreamSaver.js
The stream saver works fine in chrome mobile browser, but not in the metamask mobile browser
Here's there an example
https://jimmywarting.github.io/StreamSaver.js/examples/saving-a-blob.html