views:

138

answers:

1

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?

A: 

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];
Sney