Luis Lavena wrote:
> On Tue, Sep 14, 2010 at 11:14 AM, Amit Tomar <[email protected]>
> wrote:
>>
>> luis ,but do n't have option other than send_data and one thing i can do
>> is while downloading large files i can do it in chunks but i only
>> download 4096 byte ,this is my code
>>
>
> please read about streaming data without loading all the file contents.
>
> You will need to either use rack directly or create a mongrel handler
> to serve these files outside rails.
>
> Rails can only deliver one full request meaning it will load the full
> file before completing.
>
> --
> Luis Lavena
> AREA 17
> -
> Perfection in design is achieved not when there is nothing more to add,
> but rather when there is nothing more to take away.
> Antoine de Saint-Exupé²¹
File.open(@containerformat.location,"rb") do |f|
pos=f.tell
while @buffer = f.read(4096)
ext = File.extname(@containerformat.streamName)
if ext == ''
extension = File.extname(@containerformat.location)
#send_to_web_app(pos, buffer)
send_data(@buffer,:filename => @containerformat.name+extension,
:disposition => 'attachment')
else
send_data(@buffer,:filename => @containerformat.streamName,
:disposition => 'attachment')
pos=f.tell
end
end
now am doing it like above and trying to download 284mb of file
but only 211 bytes of file being downloaded..
why??
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Mongrel-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/mongrel-users