Browse Source

Add warning message when form data format incorrect #90

Ben Hsieh 8 years ago
parent
commit
7090203686

+ 4
- 1
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java View File

291
             FormField field = new FormField(form.getMap(i));
291
             FormField field = new FormField(form.getMap(i));
292
             list.add(field);
292
             list.add(field);
293
             String data = field.data;
293
             String data = field.data;
294
-            if (field.filename != null) {
294
+            if(data == null) {
295
+                RNFetchBlobUtils.emitWarningEvent("RNFetchBlob multipart request builder has found a field without `data` property, the field `"+ field.name +"` will be removed implicitly.");
296
+            }
297
+            else if (field.filename != null) {
295
                 // upload from storage
298
                 // upload from storage
296
                 if (data.startsWith(RNFetchBlobConst.FILE_PREFIX)) {
299
                 if (data.startsWith(RNFetchBlobConst.FILE_PREFIX)) {
297
                     String orgPath = data.substring(RNFetchBlobConst.FILE_PREFIX.length());
300
                     String orgPath = data.substring(RNFetchBlobConst.FILE_PREFIX.length());

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

11
 #import "RNFetchBlobNetwork.h"
11
 #import "RNFetchBlobNetwork.h"
12
 #import "RNFetchBlobConst.h"
12
 #import "RNFetchBlobConst.h"
13
 #import "RNFetchBlobFS.h"
13
 #import "RNFetchBlobFS.h"
14
+#import "RCTLog.h"
14
 
15
 
15
 @interface RNFetchBlobReqBuilder()
16
 @interface RNFetchBlobReqBuilder()
16
 {
17
 {
165
             {
166
             {
166
                 i++;
167
                 i++;
167
                 getFieldData([form objectAtIndex:i]);
168
                 getFieldData([form objectAtIndex:i]);
169
+                RCTLogWarn(@"RNFetchBlob multipart request builder has found a field without `data` or `name` property, the field will be removed implicitly.", field);
168
                 return;
170
                 return;
169
             }
171
             }
170
             contentType = contentType == nil ? @"application/octet-stream" : contentType;
172
             contentType = contentType == nil ? @"application/octet-stream" : contentType;