Question

What is best practice to stream multiple files in one ASIHTTPRequest?

Right now, for one file I use:

....
ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:someUrl];
[request setShouldStreamPostDataFromDisk:YES];
[request appendPostDataFromFile:someFilePath];
[request startSynchronous];

How to stream multiple files without placing all files in memory before transmission?

Was it helpful?

Solution

ASIFormDataRequest might be the better choice in this case. With this a multipart POST can be accomplished:

...
ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:url];
[request setShouldStreamPostDataFromDisk:YES];
[request setFile:someFilePath forKey:@"file1"];
[request setFile:someOtherFilePath forKey:@"file2"];
[request startAsynchronous];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top