On Fri, Dec 16, 2011 at 5:27 PM, Kyle Welsh <[email protected]> wrote:
> On Fri, Dec 16, 2011 at 11:18 PM, Chris Rossi <[email protected]>
> wrote:
>>
>> On Fri, Dec 16, 2011 at 2:24 PM, Kyle Welsh <[email protected]> wrote:
>> > Hi all,
>> >
>> > Trying to get my pyramid app to support partial and multi-threaded HTTP
>> > downloads.
>> >
>> > 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
>> >
>>
>> Here's an example of a response object that serves a file from the
>> filesystem and can handle Range requests:
>>
>> https://bitbucket.org/chrisrossi/happy/src/f2ab316ad673/happy/static.py
>>
>> Chris
>>
>> --
>> 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.
>>
>
> Thanks Chris,
>
> I am still having problems, I think maybe it might be my side.
>
> #views,py
> from demo.files import FileResponse
>
> def download(request):
>     response = FileResponse('/home/ubuntu/ubuntu-11.10-desktop-i386.iso',
> request)
>     return response
>

Looks like it should work.  What are the symptoms of these problems?

Chris

-- 
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