Skip to content

Instantly share code, notes, and snippets.

@tpope
Created April 18, 2011 02:27
Show Gist options
  • Select an option

  • Save tpope/924705 to your computer and use it in GitHub Desktop.

Select an option

Save tpope/924705 to your computer and use it in GitHub Desktop.
Carrierwave on Heroku
CarrierWave.root = Rails.root.join('tmp')
match 'uploads/*path', to: 'uploads#show'
class UploadsController < ApplicationController
def show
headers['Cache-Control'] = 'public; max-age=600'
send_file Rails.root.join("tmp/uploads/#{params[:path]}"), :disposition => 'inline'
end
end
@paulelliott
Copy link

Don't forget the requirements on the route. Without it, someone could access other files in your app with a little url hacking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment