Skip to content

Instantly share code, notes, and snippets.

@pke
Created January 25, 2012 17:46
Show Gist options
  • Save pke/1677550 to your computer and use it in GitHub Desktop.
Save pke/1677550 to your computer and use it in GitHub Desktop.
Downloading file in padrino/sinatra
Server.controllers :installer, :parent => :licenses do
before do
puts params.inspect
@license = License.get(params[:license_id])
halt 404, "License not found" unless @license
end
get :index, :with => :token do
halt 404, "File not found" if @license.installer.token != params[:token]
# installer.path is something like c:/installers/install.exe
send_file(@license.installer.path)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment