[Django]-Accessing the upload file in progress using django + nginx + apache mod_wsgi

4👍

You can monitor an upload in progress by writing your own Django upload handler. All you need to do is subclass django.core.files.uploadhandler.FileUploadHandler and implement the receive_data_chunk and file_complete methods.

Django’s upload handler documentation gives you the details you need.

3👍

It depends on your server setup. If you use Apache with mod_python then files are streamed to your Django process as they arrive. But if you run Django behind a web server using wsgi or fastcgi, then the whole file will be buffered by the server before django gets involved. Then the solution given above wont work.

This is “by design” because tying up fastcgi processes waiting for file uploads would be a big waste. So what you have to do instead is use a server module such as http://redmine.lighttpd.net/wiki/1/Docs:ModUploadProgress for Lighttpd, which implements the upload_progress view for you on the server. Or http://wiki.nginx.org/NginxHttpUploadProgressModule for nginx.

1👍

1👍

Just found an upload progress module for apache:

http://github.com/drogus/apache-upload-progress-module

What I don’t know is how (or whether) it’s works with django & mod_wsgi.

👤tback

Leave a comment