When a user clicks on a links in my Ruby on Rails app, a PDF file is generated in background.
The app is polling the server to know when the PDF file is ready, and then it should ask the user to download it as if he clicked on a PDF link that already existed.
We do this with an hidden iframe
and change the src
attribute when the PDF file is ready.
While it works on Firefox (there's a native pop up for downloading the file), it does not on safari/chrome. How should I do this? I've seen there's a Content-Disposition HTTP header, but the PDF file is stored on S3, so I don't think I can use that method.
You do need to use the Content-Disposition = 'attachment';
response header.
I'm not totally up to the play with S3 so let me know if this answer isn't quite right but it seems you are able to set the content headers in the request URL now, see example here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With