I was trying to download a file from a bucket on Amazon S3. I was wondering if I can write a javascript to download such a file from a bucket. I was googling it, but couldn\
Other answers here work, but wanted to expand on what worked for me.
In my case, I was dealing with files too large for
function download(url){
$('
to work. ( Was getting url is too long )
My solution was to include a hidden anchor tag, and trigger the click to that tag on ajax success.
You can't use the anchor tag right off the bat unless you don't care about handling errors.
S3 will respond with an XML error file if something goes wrong, so the browser will automatically display that XML response. By first attempting to hit the URL with ajax, you can catch that error without showing the ugly XML. On success in that ajax call is when you know you're clear to try and download the file.