Reputation: 347
I am using the following snippet to allow a user to download a zip file. The path here is a link on the S3 bucket. I want to confirm if the file would be directly downloaded from S3 to the browser or would it first be downloaded to the rails server & then streamed from there?
If the latter, what is the best way to avoid that?
path = "#{file.download_attachment.path}"
send_file path, :type => 'application/zip',
:disposition => 'attachment',
:filename => "#{file.name}.zip"
Upvotes: 1
Views: 8976
Reputation: 4375
The accepted answer on this question: Difference between rails send_data and send_file, with example will explain you the difference between send_file and send_data.
If you like to stream something, use send_data. If you like to send an already existing file, use send_file, so your code seems to work the way you like ;)
Upvotes: 2