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 :

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
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();, FileMode.READ);
	data = fileStream.readUTFBytes(fileStream.bytesAvailable);
	#elseif cpp
	var path:String = System.applicationStorageDirectory + "save\\";
	data = File.getContent(path + fileName + ".dat");
	return data;

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