Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex Multipart Upload Progress

I am uploading a file to a server using a multipart URLLoader. I am able to upload the file fine. I have tried to listen to the progress event on the URLLoader but it only fires at the very end of the upload. How do I get the progress event more consistently through the upload?

like image 382
asawilliams Avatar asked Sep 21 '10 01:09

asawilliams


1 Answers

Have a progress-bar:

<mx:ProgressBar width="100%" id="progBar" mode="manual" />

Register a progress event handler:

refUploadFile.addEventListener(ProgressEvent.PROGRESS, onUploadProgress);

And handle it:

private function onUploadProgress(event:ProgressEvent):void {
        var numPerc:Number = Math.round(
            (Number(event.bytesLoaded) / Number(event.bytesTotal)) * 100);
        progBar.setProgress(numPerc, 100);
        progBar.label = numPerc + "%";
        progBar.validateNow();
}

If your files are small, it is normal to not receive many events. Try with bigger files.

like image 153
Bozho Avatar answered Oct 31 '22 14:10

Bozho