我试图让用户通过左键单击链接来下载 S3 文件。通常,他们必须通过右键单击并另存为来完成。
我查看了http://apidock.com/rails/ActionController/DataStreaming/send_file但不确定这是否是我想要的。
这篇文章http://www.jtricks.com/bits/content_disposition.html基本上展示了如何通过配置 Apache 来完成。但是,我们使用的是 Heroku。
之前有人使用过 Content-Disposition 从 S3 提供文件吗?还想知道这是否占用了整个 Web 进程(Dyno)?或者如果整个过程发生在 S3 服务器上?
我试过了:
send_file 'http://some_bucket_name.s3.amazonaws.com/uploads/users/28/songs/88/test.mp3', :type => 'audio/mp3', :disposition => 'attachment'
我得到:
Cannot read file http://some_bucket_name.s3.amazonaws.com/uploads/users/28/songs/88/test.mp3
该文件确实存在。如果我手动导航到 url。该文件播放正常。