|
@@ -154,11 +154,19 @@
|
154
|
154
|
{
|
155
|
155
|
__block int i = 0;
|
156
|
156
|
__block int count = [form count];
|
|
157
|
+ // a recursive block that builds multipart body asynchornously
|
157
|
158
|
void __block (^getFieldData)(id field) = ^(id field)
|
158
|
159
|
{
|
159
|
160
|
NSString * name = [field valueForKey:@"name"];
|
160
|
161
|
NSString * content = [field valueForKey:@"data"];
|
161
|
162
|
NSString * contentType = [field valueForKey:@"type"];
|
|
163
|
+ // skip when the form field `name` or `data` is empty
|
|
164
|
+ if(content == nil || name == nil)
|
|
165
|
+ {
|
|
166
|
+ i++;
|
|
167
|
+ getFieldData([form objectAtIndex:i]);
|
|
168
|
+ return;
|
|
169
|
+ }
|
162
|
170
|
contentType = contentType == nil ? @"application/octet-stream" : contentType;
|
163
|
171
|
// field is a text field
|
164
|
172
|
if([field valueForKey:@"filename"] == nil || content == [NSNull null]) {
|