Open viskin opened 7 years ago
Here's what I did:
Check what platform it is, if it's running in a browser, download the file using this function:
export function downloadImageFromUrl(url, filename) { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); const img = new Image(); img.crossOrigin = ''; img.src = url; img.onload = function () { const img = this; canvas.width = img.width; canvas.height = img.height; ctx.drawImage(img, 0, 0, img.width, img.height); // Create hidden href const a = document.createElement('a'); a.href = canvas.toDataURL(); a.download = filename || `${Date.now()}.jpeg`; document.body.appendChild(a); a.click(); }; }
I'm using this to download firebase storage files.
Here's what I did:
Check what platform it is, if it's running in a browser, download the file using this function:
I'm using this to download firebase storage files.