S3 proxy file with Heroku and Rails

I need to send a file stored in S3 through my rails application hosted on heroku. I cannot use the redirection to the URL of the file in S3 , because I want to send a Sitemap that must be sent from the same domain as the links inside.

Ideally, I would use some kind of proxy method to send the file using the rails application, at least I can download the file in the tmp heroku directory and send it after.

I would also send the correct content type for the file.

Do you know how I can achieve this? What would be the best way?

There is a rack application that does this, but I'm not sure how to reproduce it in Rails, see the code here

thanks for the help

+7
source share
1 answer

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.

+3
source

All Articles