On Fri, 2011-12-16 at 21:24 +0200, Kyle Welsh wrote:
> Hi all,
> 
> 
> Trying to get my pyramid app to support partial and multi-threaded
> HTTP downloads.

WebOb (the package that the Pyramid request and response objects are
based on) has some internal support for ranges:

http://docs.webob.org/en/latest/file-example.html

- C
 

> 
> 
> This is what I have managed to come up with so far but it is still not
> working.
> 
> 
> Any insights into what I am doing wrong would be great.
> 
> 
> def download(request):
>     try:
>       bytes = request.GET['Accept-Ranges']
>       size = os.path.getsize('/home/kyle/test.bin')
>       f = open('/home/kyle/test.bin', 'rb')
>       f.seek(bytes)
>       response = Response(content_type='application/force-download',
> content_disposition='attachment; filename=test.bin')
>       response.app_iter = f
>       response.accept_ranges = 'bytes'
>       response.content_length = size
>     except KeyError:
>       size = os.path.getsize('/home/kyle/test.bin')
>       response = Response(content_type='application/force-download',
> content_disposition='attachment; filename=test.bin')
>       response.app_iter = open('/home/kyle/test.bin', 'rb')
>       response.accept_ranges = 'bytes'
>       response.content_length = size
>     return response
> 
> 
> Thanks in advance
> Kyle
> -- 
> You received this message because you are subscribed to the Google
> Groups "pylons-discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to pylons-discuss
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en.

Reply via email to