*I know that I should serve static files using a static file server
that was built for doing such, but save me the lecture and indulge me
on this please*

I am serving large video files (180+MB) through HttpResponse in
Django, and returning the file iteratively using Django's FileWrapper:
http://code.djangoproject.com/browser/django/trunk/django/core/servers/basehttp.py#L32

I need to prepend some data on that video file before I return the
file to the user, but I don't know how to do that without reading the
entire file into memory using .read(). Is there any way I could extend
FileWrapper to allow me to add data at the very beginning of the file,
while it's allowing the video file to be read in chunks?

Here is a simple example of what I am doing (my code has too much
other crap going on, so I wrote this):

import urllib2
from django.http import HttpResponse
from django.core.servers.basehttp import FileWrapper

def huge_video_view(request):
    response_handle = urllib2.urlopen('http://example.com/
hugeassvideo.flv')
    return HttpResponse(FileWrapper(response_handle), mimetype='video/
x-flv')

Thanks,
Brandon

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to