Don't use send_data! Especially if you're streaming a large file!

Using send_data ties up the Rails process to stream a file, something 
the front-end web server (Apache, Lighty, whatever) is FAR better suited 
to do.  Let me repeat that: using send_data means that process (Mongrel, 
FCGI) cannot accept another rails request until you're done streaming 
the file.

You can offload sending the file to front-end server using X-Sendfile 
headers. Google for your server's specific implementation of x-sendfile, 
and here's the Rails plugin to enable it:

http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/

==
Will Green

Aitor Garay-Romero wrote:
>    My first impression is that this is not directly possible in Radiant.
> 
>    You could access the send_data() method of ActionController indirectly
> through an instance or class variable.   The problem is that Radiant will
> try to render the page+layout and send it back to the user, so with the
> "extra" send_data() you will get a double render error from Rails.
> 
>     A solution is to do the send_data() in Rails code and modify the routes
> so the download request get routed to an action/controller outside Radiant.
> You could do this with one of the existing rails-on-radiant extensions
> available, or hack directly the Radiant code.
> 
>     Anyway, it would be nice to have this send-data functionality packed in
> a Radiant extension.  It looks a nice feature to have.
> 
>     /AITOR
> 
> On 11/6/07, Enzo Ferro <[EMAIL PROTECTED]> wrote:
>> Hy everybody,
>> how can I use the "send_data" method in a radius tag?
>>
>> More details:
>> in a RoR application I've used the method "send_data" to download e file
>> stored in a database table in this way:
>>
>> rhtml code:
>> <%= link_to 'Download', :action => 'download', :id => file_list.id %>
>>
>> controller code:
>> def download
>>    @file = FileList.find(params[:id])
>>    @xml = @file.xmlfile #polymorphic associations
>>    send_data(@xml.file, :type => "txt/xml", :filename =>
>> "[EMAIL PROTECTED]")
>> end
>>
>> It's work fine, but now in my radiant extension I need a tag that do the
>> same thing. I've developed this tag:
>>
>> tag "download" do |tag|
>>
>>   @file_id = request.parameters[:file]
>>   @file = FileList.find(:all, :conditions => [ "id = ?", @file_id ])
>>   @ file.each do |file|
>>      send_data("#{file.xmlfile.file}", :type => "txt/xml", :filename =>
>> "#{file.filename}")
>>   end
>> end
>>
>> It returs me the error "undefined method send_data for #"
>>
>> Anyone can help me?
>>
>> Thanks and greatings
>> --
>> Posted via http://www.ruby-forum.com/.
>> _______________________________________________
>> Radiant mailing list
>> Post:   [email protected]
>> Search: http://radiantcms.org/mailing-list/search/
>> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>>
> _______________________________________________
> Radiant mailing list
> Post:   [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
> 
> 
> ---
> avast! Antivirus: Inbound message clean.
> Virus Database (VPS): 071105-1, 11/05/2007
> Tested on: 11/6/2007 11:52:43 AM
> avast! - copyright (c) 1988-2007 ALWIL Software.
> http://www.avast.com
> 
> 
> 

_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to