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

Commit 7090203

Browse files
committed
Add warning message when form data format incorrect #90
1 parent 6c08ed7 commit 7090203

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,10 @@ private ArrayList<FormField> countFormDataLength() {
291291
FormField field = new FormField(form.getMap(i));
292292
list.add(field);
293293
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) {
295298
// upload from storage
296299
if (data.startsWith(RNFetchBlobConst.FILE_PREFIX)) {
297300
String orgPath = data.substring(RNFetchBlobConst.FILE_PREFIX.length());

src/ios/RNFetchBlobReqBuilder.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "RNFetchBlobNetwork.h"
1212
#import "RNFetchBlobConst.h"
1313
#import "RNFetchBlobFS.h"
14+
#import "RCTLog.h"
1415

1516
@interface RNFetchBlobReqBuilder()
1617
{
@@ -165,6 +166,7 @@ void __block (^getFieldData)(id field) = ^(id field)
165166
{
166167
i++;
167168
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);
168170
return;
169171
}
170172
contentType = contentType == nil ? @"application/octet-stream" : contentType;

0 commit comments

Comments
 (0)