COMMUNITY

Haxe php make post request body from streams (from file)

haxe-php

(Дмитрий Маликов) #1

i have memory limit in server
and need to make big post request 50mb or more - it possible with haxe.Http reading data from file and write to http post?


(Дмитрий Маликов) #2

found this https://api.haxe.org/haxe/Http.html#fileTransfer

but marked as deprecated

how to upload file by haxe? any example?


(Valentin Lemière) #3

https://api.haxe.org/haxe/Http.html#fileTransfer isn’t marked as deprecated, only https://api.haxe.org/haxe/Http.html#fileTransfert

The difference in naming is subtle and can easily be missed :wink:


(Дмитрий Маликов) #4

ok
where i can find example for upload file?


(Valentin Lemière) #5

Don’t know of examples, but considering the arguments it should be something like this:

var http = new haxe.Http("url");
var file = "myfile.txt";
var input = sys.io.File.read(file);
http.fileTransfer("thePostVarName", file, input, sys.FileSystem.stat(file).size);
http.request(true);
input.close();