This is my controller
Cotroller
def download
data = open(@attachment.file.url).read
@attachment.clicks = @attachment.clicks.to_i + 1
@attachment.save
send_data data, :type => @attachment.content_type, :filename => @attachment.name
end
example:
@attachment.file.url = "http://my_bucket.cloudfront.net/uploads/attachment/file/50/huge_file.pptx"
I did this, but if @attachement is a huge file (eg. 300MB), my server crash. I want to allow users to download the file in the browser directly from my AWS server?
2) tip: Do you suggest to download file from S3 (where they are stored) or with CloudFront?