Skip to content

Instantly share code, notes, and snippets.

@peterkeen
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterkeen/54196b60a3d885d36ff2 to your computer and use it in GitHub Desktop.
Save peterkeen/54196b60a3d885d36ff2 to your computer and use it in GitHub Desktop.
if Rails.env.production?
resp = HTTParty.get(@sale.product.file.url)
filename = @sale.product.file.url
send_data resp.body,
:filename => File.basename(filename),
:content_type => resp.headers['Content-Type']
else
filename = File.expand_path(Sale.last.product.file_file_name, Rails.root)
send_data File.open(@sale.product.file_file_name),
:filename => File.basename(filename),
:content_type => @sale.product.file_content_type
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment