Skip to main content
Inspiring
January 10, 2018
Answered

Why does URLLoader.bytesTotal return a different value if the file is online or local?

  • January 10, 2018
  • 1 reply
  • 598 views

I've got an xml file in my AIR app and I'm trying to determine his size. Here's what I did (seems complex so I don't know if it's the good way to do it) :

function checking_version_of_horairesXML():void{  
var url_local:URLRequest = new URLRequest("horaires3.xml");
var url_online:URLRequest = new URLRequest("http://www.mywebsite.nc/horaires3.xml");  

// Define the URLLoader.
var loader_local:URLLoader = new URLLoader();
loader_local.load(url_local);

var loader_online:URLLoader = new URLLoader();
loader_online.load(url_online); 

// Listen for when the file has finished loadingl
oader_local_Complete loader_local.addEventListener(Event.COMPLETE, loader_local_Complete);
loader_online.addEventListener(Event.COMPLETE, loader_online_Complete);  

function loader_local_Complete(e:Event):void { 
trace("size of local file : " + (URLLoader(e.target).bytesTotal));


function loader_online_Complete(e:Event):void {  t
race("size of online file : " + (URLLoader(e.target).bytesTotal)); 
}

 

It seems that the code for the local file is working as I'm getting in output :

 

size of local file: 703693

 

But I've uploaded the exact same file on my server and I have this in output :

 

size of online file : 60243

 

Why am I getting different results as these 2 files are identical ?

This topic has been closed for replies.
Correct answer Stephdidou

Weirdly, I've tried to upload it to a different server that I have (.com instead of .nc) and, the size is still different, but different that the .nc server file too (it is the SAME file) :

size of my local file : 703693

size of my online file on mywebsite.nc : 60243

size of my online file on mywebsite.com : 673031

EDIT :

Everything is getting weirder and weirder :

It seems that it depends of the server.

I've got a VPS server too. So I've tried to upload it to this one and the size is correctly display : 703693

So, on my .nc server (region where I live) the size is incorrect

on my .com server the size is bigger but still incorrect

on my vps server the is correct.

Any logical explanation for this ?

1 reply

kglad
Community Expert
Community Expert
January 10, 2018

the files are different sizes.  recheck them.

Inspiring
January 10, 2018