Now I understand better. I agree that example needs revision but:
1) files in static are automatically served properly (in a way that
supports 206)
2) dowloading uploaded files too (if you use response.download())
3) the purpose of that example is also to show that you can stream any
output stream (something with a read() method) not necessarily and
actual file (for example a StringIO).

perhaps we need to add one example.

Massimo

On Apr 5, 10:26 am, Iceberg <[email protected]> wrote:
> Sorry, chunk_size does not matter in this case. What I mean is, using
> a file object as the first parameter of response.stream(...) does NOT
> support "HTTP/1.1
> 206 PARTIAL CONTENT". Instead, we should use a file name string.
> Therefore I suggest to adjust the example document to explicitly
> compare the two approaches. I refine the doc, please refer to the end
> of this mail.
>
> On Apr5, 10:08pm, mdipierro <[email protected]> wrote:
>
> > You can do
>
> > response.stream(...,chunk_size=4000)
>
> > On Apr 5, 5:57 am, Iceberg <[email protected]> wrote:
>
> > > Hi Massimo,
>
> > > I always follow the sample here to write my streaming code:
> > >  http://www.web2py.com/examples/default/examples#streaming_examples
>
> > > Today I happened to find that this approach does not handle "HTTP/1.1
> > > 206 PARTIAL CONTENT" correctly. After some try and search, I found
> > > this:
> > >  http://groups.google.com/group/web2py/msg/8fa154c4cf1a3a38
>
> > > Therefore I suggest to adjust the stream sample. How about something
> > > like these?
>
> > > ============ START =============
> > > Example 48
>
> > > It is very easy in web2py to stream large files. Here is an example of
> > > a controller that does so:
>
> > > def streamer():
> > >     return response.stream(open('largefile.mpg4','rb'))
> > > By default all static files and files stored in 'upload' fields in the
> > > database are streamed when larger than 1MByte.
>
> > > Even better, if you use:
> > > def streamer():
> > >     return 
> > > response.stream('a_file_name_rather_than_a_file_object.mpg4',request=request)
>
> > > web2py automatically and transparently handles PARTIAL_CONTENT and
> > > RANGE requests.
>
> > > ========== THE END ===============
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to