How to download huge file from web-server

I need to download huge file from webserver to device (mac/win/ios/android).
Seems haxe.Http is not suitable for this task, since it returns whole request data - which in my case can be bigger than available memory. So there is streamed/partial download needed, to append data to local file until all bits are downloaded, without keeping all this stuff in memory

What can be used to perform such task? Any ideas welcome //

Hi, I would go with URLStream class : https://api.openfl.org/openfl/net/URLStream.html

and do something like the first answer in this post (it’s as3 but should work) :

1 Like

Thanks, looks like exactly what is needed! i was under impression this is flash only, not for all platforms…

Happy to help :slight_smile:

It is available for all platforms. OpenFL replicates the whole flash API and uses flash classes when you compile to flash/air, but it has its own classes for other platforms. Platform availability is specified for each class in the api documentation.

Typically anything you can do in as3 can be done exactly the same in openFL, with slight syntax differences.

AS3 Classes that are only available in AIR may require finding an alternate solution, for example here is a function that loads data from a file in a game :

/**

   @param	fileName
   @return
**/
static public function gameLoad(fileName:String):String
{
	var data:String = "";
	
	#if air
	
	var file:flash.filesystem.File = flash.filesystem.File.applicationStorageDirectory.resolvePath("save/" + fileName + ".dat");
	
	var fileStream:FileStream = new FileStream();
	fileStream.open(file, FileMode.READ);
	data = fileStream.readUTFBytes(fileStream.bytesAvailable);
	fileStream.close();
	
	#elseif cpp
	
	var path:String = System.applicationStorageDirectory + "save\\";
	data = File.getContent(path + fileName + ".dat");
	
	#end
	
	return data;
}

I use AIR to compile and test very quickly, but real builds target windows (c++)