lundi 24 août 2015

First attempt at file download does not work. Need to click link twice and it works

I am having a really weird situation and would appreciate any help that can be provided.

My setup is pretty simple. I have an ember app that communicates with a Rails backend. I hit a certain route and a spreadsheet report is generated and placed in the public folder of the rails app. So far so good.

The rails backend then sends a response with the path to the file to the front-end that I place in a href that people can click on to download the file. This is where the weirdness happens. The first time that the link to download is clicked, I get a 404. What's weird is that if I click the link again or copy and paste the url into the address bar, the download works. No matter how I attempt to download the file, the first attempt always fails and all subsequent attempts succeed. I even set it up so that on one click I try to download the file twice and the first attempt fails and the second one works. This is definitely not ideal though.

I have no idea what the issue is and would appreciate any help in this.

Thanks

Aucun commentaire:

Enregistrer un commentaire