views:

723

answers:

7

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?

A: 

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.

Yoni
+1  A: 

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.

bug-a-lot
Wow, very interesting articles. I did not know such restrictions were still on browsers today...As for putting files in a queue, this seems to work fine by looping through a FileReferenceList.
David
Update: I did some poking around, and the default connection limit for Firefox 3.0+ is 6. Since I have been using Firefox 3.5 for testing (and I double checked in about:config that the connection limit is 6) I again not sure what the issue is.
David
Yes, the new generation of browsers seem to have a max connection limit of 6. I've changed that number to 8 and haven't managed to upload more than 4. Both on IE and Firefox, so I'm thinking there's a further limit on the OS. Also, initially, on Firefox I had only 2 uploads active with the default value of 6. Probably a bug?
bug-a-lot
After updating the IE7 connection limit to 12, I noticed that the file uploads did start (all of them were above 0% complete), but that no progress was made on more than one file at a time.I think this goes back to an issue with how Flex is handling multiple uploads at a time (or rather... how it is not handling them...)
David
Well, depending on your connection speed and the fact that your visual updates happen in the same thread as the processing, I guess it might look that way. I've implemented the subdomain workaround for a project I'm working on and it worked wonders for me.
bug-a-lot
A: 

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

A: 

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.

Kapil Viren Ahuja
A: 

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

Muhammad Irfan
A: 

Another Free Fast Multi Site File Uploader: http://www.multisiteupload.com You can upload music, video, photos, images, files, pdf, zip… to multiple Hots with only one click in seconds. You can upload to Megaupload, DepositFiles, FileFactory, NetLoad, UploadedTo, SendSpace, Badongo, Easy Share, Loadto, MegaShare, 2Shared and HotFile. Works well. Recommended.

Ramonfer
+1  A: 

check here, also this is example

javaloper