Reputation: 1075
I am using dragonfly to handle my attachments and s3 to store the assets.
I know i can serve directly from s3 but my client has locked down internet access so cant access them. So what i need to do is proxy the images through my domain.
data = open(@training_doc.upload.remote_url).read
send_data data, :filename => @training_doc.upload.name
Thats what I have but it doesn't allow me to render it inline (in the tab its self) rather it downloads it which isn't ideal.
I know i can do this to render it inline but this isn't proxied
redirect_to @training_doc.upload.remote_url(:expires => 2.hours.from_now, :query => {'response-content-disposition' => 'inline'})
I know in rails you can use send_file but that only works when you have it in the normal file system
Is their any other ways/ way to achieve this?
Upvotes: 0
Views: 502
Reputation: 106782
The send_data
method has a disposition
option that can be set to inline
:
data = open(@training_doc.upload.remote_url).read
send_data(data,
:filename => @training_doc.upload.name,
:type => 'application/pdf',
:disposition => 'inline'
)
Upvotes: 2