Is it possible to rename a file name before user right-click’s + save as with Carrierwave + S3 + Heroku + Content-Disposition? I’m thinking of sanitizing file names (e.g. 193712391231.flv) before the file is saved on the S3 server and saving the original file name in a column in the db.
When a user decides to download the file (right-click and save as). I can’t serve / send it as 193712391231.flv. Instead, I would like to send the file with its original file name.
How can this be implemented?
Using Carrierwave. I’ve come across this:
uploaded = Video.first.attachment
uploader.retrieve_from_store!(File.basename(Video.first.attachment.url))
uploader.cache_stored_file!
send_file uploader.file.path
This wont be served by S3, because it first caches the file in the local filesystem and then sends it to the browser. Which takes up a whole web process (Dyno in Heroku).
If anyone has any ideas, please suggest.
If you’re sending the file to the user direct from S3 you’ve no option. If you route the file through a dyno you can call it what you want, but you’re using a dyno for the entire duration of the download.
I would store the files in a user friendly manner where possible and use folders to organise them.