Copy link to clipboard
Copied
Hi,
I am writing an application which detects the bandwidth of the Client machine. A new requirement needs me to detect both the upload andd download speeds seperately. Is this possible. Please guide me through the process.
Thanks in Advance.
Copy link to clipboard
Copied
Hi prithvi,
can i ask , r u using the socket class for this ?
Copy link to clipboard
Copied
no, i'm not using socket class.
Copy link to clipboard
Copied
upload:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html
The FileReference class can upload a file and has events for progress to handle the upload.
download:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html
The URLLoader can perform the download and give you the progress events.
Just monitor a quick upload and download with the progress events. Average the speed as you get events and you'll know the approximate speed. The longer the upload or download the more accurate you'll be but also waste more bandwidth doing it. If this is for a device then be careful about using too much data and I'd do it once and never again if possible. If it's a desktop computer it's potentially less of an issue but the user can still be tethered to a cell via a laptop.
Copy link to clipboard
Copied
i tried with fileReference class.
but fileReference is user interaction.
So I thought to upload an image to server without user interaction.
how to do this?
Copy link to clipboard
Copied
Yes the user chooses a file of any size to perform the test. You'd have to do that to use the easy upload method of FileReference as it won't work until browse is invoked.
I didn't know you needed to do it silently but if you do want to you can always download a file first from your server using URLLoader. Then once you have it loaded in flash you can re-send that same file back on a lower level using the Socket class. This isn't really something easily explained here but take a look at the class:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/Socket.html
You can send the same data you downloaded right back to something using that class to something like a FTP server. This is a pretty common thing and there's lots of examples online about uploading files to a FTP server using the Socket class.