Does anyone have any simple code samples for Django + SWFUpload? I have it working perfectly in my PHP application but Django is giving me headaches.
Unfortunately I can't give you any very detailed code samples, but I have quite a bit of experience with working with SWFUpload + Django (for a photo sharing site I work on). Anyway, here are a few pointers that will hopefully help you on your quest for DjSWF happiness :)
You'll want to use the cookies plugin (if of course you are using some sort of session-based authentication [like
django.contrib.auth
, and care who uploaded what).The cookies plugin sends the data from cookies as POST, so you'll have to find some way of getting this back into
request.COOKIES
(process_request
middleware that looks for asettings.SESSION_COOKIE_NAME
inrequest.POST
on specific URLs and dumps it intorequest.COOKIES
works nicely for this :)Also, remember that you must return something in the response body for SWFUpload to recognize it as a successful upload attempt. I believe this has changed in the latest beta of SWFUpload, but anyway it's advisable just to stick something in there like 'ok'. For failures, make use of something like
HttpResponseBadRequest
or the like.Lastly, in case you're having trouble finding them, the uploaded file is in
request.FILES
:)
If you have anything perplexing I haven't covered, feel free to post something more detailed and I'll be happy to help.
Django version of the samples for SWFUpload:
http://github.com/naltimari/django-swfupload-samples/tree/master
So long uploadify. Great idea but it is just buggy, especially on Windows.
I wrote a blog article about doing this: http://blog.fogtunes.com/?p=69