Hi all, Just to let you know that there's an X-Sendfile implementation for WSGI apps (inc. Django), which also works with Nginx: https://launchpad.net/wsgi-xsendfile
You can use it in Django views via twod.wsgi. For example: """ from twod.wsgi import call_wsgi_app from xsendfile import NginxSendfile file_sender = NginxSendfile('/var/www/docs') file_sender_wsgi_app = XSendfileApplication('/media/documents', file_sender) def django_view(request, article_id): article = Article.objects.get(article_id) if it's foggy: doc_response = call_wsgi_app( file_sender_wsgi_app, request, article.path, ) else: doc_response = HttpResponseForbidden() return doc_response """ That package is pretty stable, the only thing it's missing is documentation which should be sorted soon. Cheers. - Gustavo. On Mar 25, 6:50 am, Waldemar Kornewald <wkornew...@gmail.com> wrote: > On Thursday, March 24, 2011 2:40:39 PM UTC+1, Kristaps Kūlis wrote: > > > I wish to note that Nginx implements this feature differently than > > LigHTTPd and Apache2 > >http://wiki.nginx.org/XSendfile, > > > Should django implementation consider that ? > > > My proposal to implement would be: > > 1. HttpFileResponse which takes file location (relative to MEDIA_URL ?) > > 2. HttpFileResponse checks for settings.X_SENDFILE or > > settings.X_ACCEL_REDIRECT and modifies sets revelant headers > > (Content-Type, X-Sendfile, X-Accel-Redirect) etc. HttpFileResponse > > should fallback to outputting file if no accelerated redirect is > > available. > > 3. Update docs, showing example server config . > > 4. Tests > > > I could provide patch, if design idea is ok . > > You might also be interested in this ticket which goes a little bit further > in abstracting file uploads and downloads not only for X-Sendfile, but also > S3, App Engine, and other file hosting/serving > solutions:http://code.djangoproject.com/ticket/13960 > > The patch is not great. It's too complicated, both implementation-wise (esp. > in django.forms) and usability-wise (esp. the transfer_id stuff which is > used for assigning backends to uploads/downloads). > > For the sake of completeness, here is a separate app with the same > purpose:http://www.allbuttonspressed.com/projects/django-filetransfers > The API can certainly be simplified some more and I plan to do that probably > in May. > > I hope some of this is useful to you. > > Bye, > Waldemar > > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.