python - AJAX uploads issue in Django app -
i have followed tutorial posted here in order ajax file uploads on django app. thing doesn't work, , closest issue finding out save_upload() method raises following exception: 'wsgirequest' object has no attribute 'read'. ideas on doing wrong?
edit: figured out works in django 1.3. ideeas on how make work in django 1.2?
i think have gotten bottom of problem.
1) trying run .read() on request object, not allowed. instead, need run on request.raw_post_data.
2) before can run .read(), takes file-like object, need convert str file-like object.
try this:
import stringio output = stringio.stringio() output.write(request.raw_post_data)
...now you'll able run output.read() , data want.
#loop through, writing more of file each time file_so_far = output.read( 1024 ) #get ready.... while file_so_far: #..get set... dest.write( file_so_far ) #go. file_so_far = output.read( 1024
Comments
Post a Comment