andyburke / UnityHTTP

A TcpClient-based HTTP library for Unity.
GNU General Public License v2.0
592 stars 146 forks source link

StreamedWWWForm for memory efficient files upload #44

Closed jkb0o closed 9 years ago

jkb0o commented 9 years ago

With StreamedWWWForm you can upload large files without loading them into memory.

var form = new HTTP.StreamedWWWForm();
form.AddField("name", "big_one.bundle");
form.AddFile("data", "bundles/big_one.bundle");
var request = new HTTP.Request("POST", "http://127.0.0.1:8888/upload", form);
request.synchronous = true;
request.Send();
HTTP.Response response = request.response;
if (response.status == 200){
    Debug.Log("Bundle " + name + " uploaded in " + (request.responseTime/1000f).ToString("F") + " seconds" );
} else {
    Debug.LogError("Error uploading bundle to server: [" + response.status + "] " + response.Text);
}