Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 8c4d56f

Browse files
committed
Add IOS empty form data field checking #90
1 parent 4051817 commit 8c4d56f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ios/RNFetchBlobReqBuilder.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,19 @@ +(void) buildFormBody:(NSArray *)form boundary:(NSString *)boundary onComplete:(
154154
{
155155
__block int i = 0;
156156
__block int count = [form count];
157+
// a recursive block that builds multipart body asynchornously
157158
void __block (^getFieldData)(id field) = ^(id field)
158159
{
159160
NSString * name = [field valueForKey:@"name"];
160161
NSString * content = [field valueForKey:@"data"];
161162
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+
}
162170
contentType = contentType == nil ? @"application/octet-stream" : contentType;
163171
// field is a text field
164172
if([field valueForKey:@"filename"] == nil || content == [NSNull null]) {

0 commit comments

Comments
 (0)