1

I'm having a hard time trying to figure this out.

I have a button_to that should download a .mp4 movie that is stored on S3 when clicked. Since the audience is very basic, I need that when they click the button the download start right away. No right-click and Save As, just a button to send the file as download instead of open it on the browser.

I tried using send_file only to realize that it works for local files.

Any idea how to do this?

Martin
  • 11,216
  • 23
  • 83
  • 140

2 Answers2

1

Just solved it using a link_to instead and link directly to the S3 file. Amazon automatically send the file to download instead of open in on the browser. Easier than I thought.

Martin
  • 11,216
  • 23
  • 83
  • 140
0

I would recommend just making it be a YouTube video. If you need privacy, make it an unlisted YouTube video.

If that is not an option, you should try to configure S3 to serve the following http header when delivering the file:

Content-Disposition:  attachment
David Grayson
  • 84,103
  • 24
  • 152
  • 189
  • Can you elaborate on the later? – Martin Sep 29 '12 at 17:12
  • 1
    You want to deliver a movie to people over HTTP. Every HTTP connection consists of a request with some headers (key-value pairs like A: B) and a body, and a response with some headers and a body. You can see the request and reponse headers with `curl -I` IIRC, or by using the Developer Tools in Chrome. If Amazon delivers the correct Content-Disposition header to the user's browser in the response, it should cause the browser to download the file instead of displaying it inline. – David Grayson Sep 29 '12 at 17:42
  • I don't know much about configuring Amazon S3, but you should search for things like "Amazon S3 content-disposition" and read http://stackoverflow.com/questions/2613792/change-content-disposition-of-existing-s3-object and read http://stackoverflow.com/questions/870215/force-download-with-php-on-amazon-s3?lq=1 – David Grayson Sep 29 '12 at 17:43