Uploading multiple files simultaneously with Flex

2019-02-05 10:30发布

I have been working on a flex uploader, where the user can select multiple files.

It works fine when the files are uploaded in a queue (one at a time), however as soon as I try to have it upload 2 files at once I run into issues.

It seems that files will often lock up, and either stay at 1% until every other file is uploaded, or just not complete at all. There is never more than one file uploading at a time.

Is there some issue with calling .upload on multiple files at once in Flex?

5条回答
ら.Afraid
2楼-- · 2019-02-05 11:18

Unfortunately it's a browser limitation of 2 (depending on browser) active connections per host. Meaning only 2 uploads will be active at a time, while the other will be queued. Now this normally wouldn't really be a problem but when the uploaded files are pretty large, the other uploads will time out, even though they didn't start. There's a workaround in using subdomains every 2 uploads (upl1.mydomain.com, upl2.mydomain.com) that I didn't get to test but it should do the trick.

References: http://anirudhs.chaosnet.org/blog/2008.06.17.html and http://www.ajaxperformance.com/2006/12/18/circumventing-browser-connection-limits-for-fun-and-profit/ (which you can get to from the first link actually).

Also, you probably won't be able to queue the uploads in flash, because the security model requires upload method (of the FileReference) to be called as a result of a mouse click.

查看更多
我想做一个坏孩纸
3楼-- · 2019-02-05 11:22

I don't have a direct answer to your question, but the gmail uploader comes to mind. It uses swfupload (updated link), which is open source so you can probably figure it out from the source.

There's more info in this answer.

查看更多
Explosion°爆炸
4楼-- · 2019-02-05 11:23

Making the upload script as upload class may help.. i mean if your uploading script is in php or asp then make the class of that script so that each request corresponds to each unique object and we can upload files simultaneously...

查看更多
放荡不羁爱自由
5楼-- · 2019-02-05 11:30

Another way to simulate multitasking is downloading / uploading by chunks and use callLater() for sequential execution. That would be a replication of early Windows cooperative multitasking

查看更多
太酷不给撩
6楼-- · 2019-02-05 11:33

The problem is with the model in which Flex connects to the back-end. With HttpService and Remoting, Flex clients opens a Http connection to the server. If you are connecting to the same Servlet / service on the server, it will use the same connection and can run into issues.

For a simple test, try create two instances of the same servlet and send upload requests to 2 servlets for 2 uploads. It should work.

查看更多
登录 后发表回答