Send large file with rails

165 views
Skip to first unread message

Nicolò Benigni

unread,
Sep 22, 2015, 6:10:58 AM9/22/15
to rubyonra...@googlegroups.com
Hi,

I am having problem with sending file to browser with rails, to let the
user download them.


Here is my situation:

I have built a little webmail client, and I need to make attachments
downloadable to the users. I have the base64 ecoded rappresentation of
the file, and I don't know how to generate and send the file.


I have tried send_data, with disposition :attachment, but the request
take a lot of time and it doesn't even prompt the download dialog. I am
surely missing the whole point here, and I need some clarity.

thanks

--
Posted via http://www.ruby-forum.com/.

Frederick Cheung

unread,
Sep 22, 2015, 7:04:21 AM9/22/15
to Ruby on Rails: Talk


On Tuesday, September 22, 2015 at 11:10:58 AM UTC+1, Ruby-Forum.com User wrote:

I have built a little webmail client, and I need to make attachments
downloadable to the users. I have the base64 ecoded  rappresentation of
the file, and I don't know how to generate and send the file.


I have tried send_data, with disposition :attachment, but the request
take a lot of time and it doesn't even prompt the download dialog. I am
surely missing the whole point here, and I need some clarity.


You really want to be using send_file rather than send_data, because send_data ties up your rails process sending the data whereas send_file will offload to apache/nginx  if properly setup (on apache this requires the X-Sendfile module, I forget what the nginx equivalent is)

Fred
Reply all
Reply to author
Forward
0 new messages