是不是可以用异步来完成? ajax upload

2012/8/8 Russell Keith-Magee <russ...@keith-magee.com>

> On Wed, Aug 8, 2012 at 2:42 PM, 春燕 李 <lcy8...@gmail.com> wrote:
> > 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?
>
> Not really. This isn't something that's Django specific -- it's a
> general problem with web browsers. Web browsers make requests.
> Background requests are still requests, and they need to happen in the
> context of a page that is in the foreground. If you change the
> foreground page, you're going to stop any background activity that is
> underway.
>
> That said, there might be something you can do by breaking the
> background task into a large number of smaller requests using the HTTP
> Range header, and then recombining the file on the server side from
> all the individual chunks. That won't stop the background request from
> being killed, but it will give you an opportunity to resume the upload
> on a new page.
>
> However, this isn't something where I can point you at a simple page
> of documentation and say "just call these three lines of Python". What
> you're proposing isn't a simple task. You're going to need to become
> very familiar with the HTTP specification, and work out how to put the
> pieces together yourself.
>
> 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.
>
>

-- 
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.

Reply via email to