After a lot of pain, I ended up getting the add-on ( http://www.uploadify.com/ ) while working with django, but the problem was not really django, but getting it to work with the Apple Mac; browsers on this platform do not serve cookies from Flash; you need to install them manually:
Therefore, I include them in my render answer:
return render_to_response('files_upload.html', { 'session_cookie_name': settings.SESSION_COOKIE_NAME, 'session_key': request.session.session_key
And submit them from the download via the configuration specified in the template:
$(document).ready(function() { $('#fileInput').uploadify({ 'scriptData': {'{{session_cookie_name}}': '{{session_key}}'},
I saw how this improved with the help of a decorator over the view, but it was a dirty hack that I used in the middleware to copy the POST to COOKIE before the session middleware did the session restore.
class FakeUploadCookieMiddleware(object): """TODO: replace the hardcoded url '/upload' with a 'reverse'.""" def process_request(self, request): if request.path == '/upload/' \ and request.POST.has_key(settings.SESSION_COOKIE_NAME): request.COOKIES[settings.SESSION_COOKIE_NAME] = \ request.POST[settings.SESSION_COOKIE_NAME] logging.debug('Faking the session cookie for an upload: %s', \ request.POST[settings.SESSION_COOKIE_NAME])
source share