Download file on click - Ruby on Rails

前端 未结 2 1882
北海茫月
北海茫月 2021-02-06 12:18

My application is using Rails 2 backend, Heroku for hosting, Paperclip for file uploads, and Amazon S3 for file storage.

Right now users can upload files with paperclip

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-06 12:51

    When you transfer the file, you need to set a Content-Disposition header with a value of attachment; filename=yourfilename.pdf. If it's transfered directly from S3, you'll need to tell S3 to set the Content-Disposition headers as well. Possibly also Content-Type.

    Note that if you tell S3 to associate a Content-Disposition header, it will always transmit this header.

    FWIW, here's Amazon's documentation on doing a PUT for an Object: http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectPUT.html

提交回复
热议问题