Thanks ! In my application, I want to upload image files(such as *.iso) which are always large, it will take long time before the uploading completed. During this time, I cannot send out other request on current page, because a new request will refresh the current page and make the uploading failed. My aim is that after I click the Upload button, the file uploading is processed in backend, I can send out other request simutanously. Firstly , I tried to get the stream, and write new handler to replace the exsiting processing. But after I read the source code , I find that the input stream got by django is activity limited, it only can be read once, once reading is started, the current page shouldn't be refresh, or else the stream reading will be failed.
Is it realizable to uploading backend and simutanously send other request on current page, and the uploading won't interrupt because of leaving this page? Thanks again! Yours, C. Y. Lee On 8月8日, 上午11时53分, Russell Keith-Magee <russ...@keith-magee.com> wrote: > On Wed, Aug 8, 2012 at 10:11 AM, 春燕 李 <lcy8...@gmail.com> wrote: > > As you know, Django can process file uploading with its own > > uploadhandler. But all the request data is processed as stream, and > > mod_wsgi provides a way to read the stream, what you can do is just > > read the stream sequentially, which means that you cannot separate > > file stream from the request input stream. When you upload file , it > > won't response immediately , you have to wait till file uploading has > > completed. > > > Is there any way to separate file stream from request input stream, > > so I can process and save the file independently to avoid long time > > waiting during file uploading? > > Yes, it is possible. What you need to do is separate the file upload > from the page request. > > A good example of how this works is inside Gmail itself. When you > attach a file to an email in Gmail, the Gmail interface disables the > send button, and sets up a background request (stimulated by > Javascript) that uploads the file. When the background file upload > completes, the Javascript handling the upload request reenables the > "send" button. You then send your email, submitting the non-file > content to the server. > > There isn't anything particularly special you need to do from a Django > perspective -- the file upload is handled using a normal > file-uploading view. The only difference is on the user interface > side, because the user is effectively interacting with *2* views -- > one that they can see, and one that is hidden and only used by the > background upload. > > A quick search of Google will give you lots of examples of how to > handle background file uploads in this way. > > Yours, > Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.