I am trying to use Valum's Ajax Upload to do file uploads on a Django-
based site I am making.  Currently I am avoiding a form simply because
AU sends the upload as the entirety of the POST data in an ajax
request.  Right now I have a very naive approach to doing this:

upload = SimpleUploadedFile( filename, request.raw_post_data )
<and then I loop through the chunks to write to disk>

This works great... on small files.  I've tested with PDFs, various
other files, and up to the ~20MB Google Chrome deb package and they
all do great.  However, if I move up to something like a CD or DVD iso
it bombs horribly.  Often Django sends back an Out of Memory
response.  On the surface this makes sense since SimpleUploadedFile is
an in-memory version of the upload classes.  I cannot see how to use
TemporaryUploadedFile because it does not take actual content in its
constructor.  As a side note: I would think after using up the
available RAM it would go to virtual memory, but whatever.

So, my question is, how do I get this to work?  Is there a better way
to read in the file?  I tried directly reading the raw_post_data via
Python's IO (system uses 2.6.5) but FileIO's ascii encoder/decoder
will obviously complain about non-ascii characters when working with
binary files.  I have not been able to find info on changing the
encoder/decoder.

I wouldn't mind passing the data into a form and having Django do the
work of picking the right upload class and so on, but I cannot figure
out how to pass it because something like

upload_form = UploadForm( request.POST, request.FILES )

will not work because the POST contains the file and not the normal
Django info and FILES does not exist.

As I said, I'm not worried about the method of the solution, just that
I get something that works!  Thanks!

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

Reply via email to