Proxy a file from S3 with Heroku and Rails
I need to send a file stored in S3 through my rails application hosted on heroku. I cannot use a redirect to the URL of the file on S3 as I want to send a sitemap which should be served from the same domain as the links inside.
Ideally, I would use some sort of proxy method to send the file by the rails app, at least, I can download the file in the tmp directory of heroku and send it after.
I would also send the right content-type for the file.
Do you know how can I achieve it ? What will be the best way ?
There is a rack app which is doing that but I'm not sure how to reproduce it in Rails, see the code here
Thanks for your help
It looks like this:
blob = AWS::S3::S3Object.value( filename, bucketname )
send_data( blob,
{ :type => 'image/jpg,
:disposition => 'inline' } )
the type can be image/jpg, image/gif, etc
链接地址: http://www.djcxy.com/p/10310.html