On Wed, Aug 8, 2012 at 10:11 AM, 春燕 李 <[email protected]> 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 [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