I'm using Carrierwave
to upload files to my app. I'm also using the Fog
gem to store my files on S3
, and on top of that, I'm creating a distribution in CloudFront
for everything inside my bucket.
I have several questions...
- I need to create 'file downloads', so I need to edit
response-content-disposition
. It seems to be (looking at examples), this can already be done with Fog or Carrierwave... but when I try passing inurl(20, :query => { "response-content-disposition" => "xyz" })
like the documentation says (20 is the expire time), it states that it only expects one argument. So my question is, how do I set an expire time for URL's?
After I couldn't find anything there, I tried authenticated_url
which also only takes 1 argument, and puts the expire time at 10 minutes. I'm sure I can set this globally in a config but I have no idea why I wouldn't be able to set this on a per link basis?
Here is the code I have so far:
def download_link(download)
file = download.filename.file
filename = file.filename
extension = file.extension
options = {
:query => {
"response-content-type" => download_content_type(extension),
"response-content-disposition" => "attachment; filename=#{filename}"
}
}
file.authenticated_url(options)
end
- It's my understanding that I cannot have a CF Distribution which is both private and public. I have no problem making my download links all private, but the images on my site are also hosted here... which means every image on my site would need an authenticated URL. That wouldnt be so bad I suppose unless later on I want to cache, which would be a problem. So, I suppose here my best bet would be to make a new bucket just for images that is public?