Reputation: 1
Hope you guys are doing fine.
We are developing a functionality where customers can click on the download button and download an image. Image is stored in S3 and a public URL is generated which is kept behind the button.
Something like
<a href="S3Url">Download</a>
Current exp: When customer clicks on the download button
So need assistance on
Note:
Sample:
var downloadElement = document.createElement('a');
downloadElement.href = S3Url;
downloadElement.click();
Upvotes: 0
Views: 501
Reputation: 144
You can try adding the download
attribute to your links. This allows it work correctly for me using Safari.
Something like this, perhaps:
var downloadElement = document.createElement('a');
downloadElement.href = S3Url;
downloadElement.download = "filename.jpg";
downloadElement.click();
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download
Upvotes: 0