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

Commit 8bdf5b0

Browse files
committed
combine unnecessary allocation.
add line to empty catch. use TextUtil.isEmpty. Boolean -> boolean (new field only)
1 parent 298d6ae commit 8bdf5b0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class RNFetchBlobConfig {
2020
public long timeout = 60000;
2121
public Boolean increment = false;
2222
public ReadableArray binaryContentTypes = null;
23-
public Boolean largeFileUpload;
23+
public boolean largeFileUpload;
2424

2525
RNFetchBlobConfig(ReadableMap options) {
2626
if(options == null)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Intent;
55
import android.net.Uri;
66
import android.os.Bundle;
7+
import android.text.TextUtils;
78

89
import com.facebook.react.modules.network.*;
910

@@ -78,17 +79,16 @@ protected void onHandleIntent(final Intent intent) {
7879
: MediaType.parse("application/octet-stream");
7980
if(filename != null && data.startsWith("RNFetchBlob-")) {
8081
try {
81-
String newData = data.replace(RNFetchBlobConst.FILE_PREFIX, "");
82-
String normalizedUri = RNFetchBlobFS.normalizePath(newData);
82+
String normalizedUri = RNFetchBlobFS.normalizePath(data.replace(RNFetchBlobConst.FILE_PREFIX, ""));
8383
file = new File(String.valueOf(Uri.parse(normalizedUri)));
8484
} catch (Exception e) {
85-
//
85+
file = null;
8686
}
8787
}
8888

8989
String contentDisposition = "form-data"
90-
+ (name != null && name.length() > 0 ? "; name=" + name : "")
91-
+ (filename != null && filename.length() > 0 ? "; filename=" + filename : "");
90+
+ (!TextUtils.isEmpty(name) ? "; name=" + name : "")
91+
+ (!TextUtils.isEmpty(filename) ? "; filename=" + filename : "");
9292

9393
requestBuilder.addPart(
9494
Headers.of("Content-Disposition", contentDisposition),

0 commit comments

Comments
 (0)