This repository was archived by the owner on Mar 16, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
src/android/src/main/java/com/RNFetchBlob Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -242,10 +242,10 @@ private ArrayList<FormField> countFormDataLength() {
242
242
ArrayList <FormField > list = new ArrayList <>();
243
243
ReactApplicationContext ctx = RNFetchBlob .RCTContext ;
244
244
for (int i = 0 ;i < form .size (); i ++) {
245
- ReadableMap field = form .getMap (i );
246
- list .add (new FormField ( field ) );
247
- String data = field .getString ( " data" ) ;
248
- if (field .hasKey ( " filename" ) ) {
245
+ FormField field = new FormField ( form .getMap (i ) );
246
+ list .add (field );
247
+ String data = field .data ;
248
+ if (field .filename != null ) {
249
249
// upload from storage
250
250
if (data .startsWith (RNFetchBlobConst .FILE_PREFIX )) {
251
251
String orgPath = data .substring (RNFetchBlobConst .FILE_PREFIX .length ());
@@ -274,7 +274,7 @@ private ArrayList<FormField> countFormDataLength() {
274
274
}
275
275
// data field
276
276
else {
277
- total += field .getString ( " data" ). length ();
277
+ total += field .data != null ? field . data . length () : 0 ;
278
278
}
279
279
}
280
280
contentLength = total ;
@@ -301,8 +301,9 @@ public FormField(ReadableMap rawData) {
301
301
else {
302
302
mime = filename == null ? "text/plain" : "application/octet-stream" ;
303
303
}
304
- if (rawData .hasKey ("data" ))
304
+ if (rawData .hasKey ("data" )) {
305
305
data = rawData .getString ("data" );
306
+ }
306
307
}
307
308
}
308
309
You can’t perform that action at this time.
0 commit comments