Browse Source

Add IOS empty form data field checking #90

Ben Hsieh 8 years ago
parent
commit
8c4d56ff27
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      src/ios/RNFetchBlobReqBuilder.m

+ 8
- 0
src/ios/RNFetchBlobReqBuilder.m View File

@@ -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]) {