Flash upload link speed *

  • classified
  • Expert
  • Expert
  • User avatar
  • Posts: 540
  • Loc: Bahrain

Post 3+ Months Ago

Greetings mates ,

im developing an application that will calculate the link/bandwidth download/upload speed .
i have done the download speed part , having troubles figuring out how will i calculate the upload speed .

thing is , if i used the filereference the user will have to browse for a file to upload , not really a good idea .
another way is to send characters or a collection of strings to the server using loadvars and calculate the time difference end - start / chunksize . but im not really sure if this is the right way to do it, as i need an instant live output .

Ideas , anyone ?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

If you generate garbage data to send, you're still going to be able to watch the progress of the upload via BytesLoaded/BytesTotal aren't you ? :scratchhead:
  • classified
  • Expert
  • Expert
  • User avatar
  • Posts: 540
  • Loc: Bahrain

Post 3+ Months Ago

thats if i used the flash file reference , not the loadvars me thinks ...
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

I don't know, I remember using those before the FileReference class was ever available. They've got to be in there somewhere.
  • classified
  • Expert
  • Expert
  • User avatar
  • Posts: 540
  • Loc: Bahrain

Post 3+ Months Ago

you can use that for the data being pulled ...
http://livedocs.adobe.com/flash/8/main/ ... 02327.html

but thanks for the idea , i'll find away sooner or later , getting there .

if you got more ideas let me know .
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

I know this post may be a bit late but i have a solution that works for me that can be modified to fit the load vars issue.

speed calculation:
ACTIONSCRIPT Code: [ Select ]
var last_bytes_loaded:Number = 0;
var last_time:Number = 0;
var speed:String;
 
// Format size
function format_size(size) {
   
    // Make the array that holds the unit of mesaure
    var units:Array = new Array("B","KB","MB","GB","TB","PB","EB","ZB","YB");
   
    // Loop through our units
    for(u=0; u<units.length; u++) {    
       
        // Check to see if we are at the larest number for the unit
        if((size / Math.pow(1024,u)) >= 1) {
           
            // Add the new size and the unit
            new_size = Math.floor((size / Math.pow(1024, u)) * 100) / 100;
            unit = units[u];
       
        }
   
    }
   
    // Return the newsize and unit
    return new_size + unit;  
 
}
 
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
   
    // Make a temp date
    var temp_date:Date = new Date();
   
    // Check to see if the seconds are different
    if(last_time != temp_date.getSeconds()) {
       
        // Set the last seconds to be the current
        last_time = temp_date.getSeconds();
 
        // Format the speed string
        speed = format_size(bytesLoaded - last_bytes_loaded);
 
        // Set the last bytes loaded to the bytesloaded
        last_bytes_loaded = bytesLoaded;     
   
    }
 
}
 
 
  1. var last_bytes_loaded:Number = 0;
  2. var last_time:Number = 0;
  3. var speed:String;
  4.  
  5. // Format size
  6. function format_size(size) {
  7.    
  8.     // Make the array that holds the unit of mesaure
  9.     var units:Array = new Array("B","KB","MB","GB","TB","PB","EB","ZB","YB");
  10.    
  11.     // Loop through our units
  12.     for(u=0; u<units.length; u++) {    
  13.        
  14.         // Check to see if we are at the larest number for the unit
  15.         if((size / Math.pow(1024,u)) >= 1) {
  16.            
  17.             // Add the new size and the unit
  18.             new_size = Math.floor((size / Math.pow(1024, u)) * 100) / 100;
  19.             unit = units[u];
  20.        
  21.         }
  22.    
  23.     }
  24.    
  25.     // Return the newsize and unit
  26.     return new_size + unit;  
  27.  
  28. }
  29.  
  30. listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
  31.    
  32.     // Make a temp date
  33.     var temp_date:Date = new Date();
  34.    
  35.     // Check to see if the seconds are different
  36.     if(last_time != temp_date.getSeconds()) {
  37.        
  38.         // Set the last seconds to be the current
  39.         last_time = temp_date.getSeconds();
  40.  
  41.         // Format the speed string
  42.         speed = format_size(bytesLoaded - last_bytes_loaded);
  43.  
  44.         // Set the last bytes loaded to the bytesloaded
  45.         last_bytes_loaded = bytesLoaded;     
  46.    
  47.     }
  48.  
  49. }
  50.  
  51.  


the above code is what i use for the file reference to use the load vars i would use php with the pecl package along with the function uploadprogress_get_info(); to get the info and then you can either convert the function above to work in php or to return the bytes totla and bytes uploaded

PHP Code: [ Select ]
// Make an array of the file information... $id is the UPLOAD_IDENTIFIER setup in the html form <input type="hidden" name="UPLOAD_IDENTIFIER" value="random_value" />
$upload_info = uploadprogress_get_info($id);
 
// Get the total size and current upload status
$bytes_uploaded = intval($upload_info['bytes_uploaded']);
$bytes_total    = intval($upload_info['bytes_total']);
 
  1. // Make an array of the file information... $id is the UPLOAD_IDENTIFIER setup in the html form <input type="hidden" name="UPLOAD_IDENTIFIER" value="random_value" />
  2. $upload_info = uploadprogress_get_info($id);
  3.  
  4. // Get the total size and current upload status
  5. $bytes_uploaded = intval($upload_info['bytes_uploaded']);
  6. $bytes_total    = intval($upload_info['bytes_total']);
  7.  
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Even though your post might be a couple years too late, it's a nice solution and one that I'm sure will benefit others. Thanks for taking the time to post it.
  • bluego78
  • Born
  • Born
  • bluego78
  • Posts: 1

Post 3+ Months Ago

Hi everybody!
Your post is really great, there's nothing else about this argument anyway...
I need to create a speed test for internet connection, (example speedtest dot net) but
i can't find any tutorial, anything can help me with this...

Please please please... can you help me?
Try to explain me what i have to do, or post me some example..

you're my only hope :-)

Thanks!!
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

I am currently looking it to more options for you but i have found one that uses the flash media server to help out www . derekentringer . com/blog/flash-bandwidth-port-detection/

So far it looks like the flash media server is the way to go

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 17 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.