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) :
Thanks, looks like exactly what is needed! i was under impression this is flash only, not for all platforms…
Happy to help
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 :
static public function gameLoad(fileName:String):String
var data:String = "";
var file:flash.filesystem.File = flash.filesystem.File.applicationStorageDirectory.resolvePath("save/" + fileName + ".dat");
var fileStream:FileStream = new FileStream();
data = fileStream.readUTFBytes(fileStream.bytesAvailable);
var path:String = System.applicationStorageDirectory + "save\\";
data = File.getContent(path + fileName + ".dat");
I use AIR to compile and test very quickly, but real builds target windows (c++)