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

Commit f307c69

Browse files
committed
Fix android stat bug when stat asset file
1 parent 0bd9e0e commit f307c69

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,11 @@ protected Integer doInBackground(String ...args) {
555555
*/
556556
static void stat(String path, Callback callback) {
557557
try {
558-
callback.invoke(null, statFile(path));
558+
WritableMap result = statFile(path);
559+
if(result == null)
560+
callback.invoke("stat error: failed to list path `" + path + "` for it is not exist or it is not a folder", null);
561+
else
562+
callback.invoke(null, result);
559563
} catch(Exception err) {
560564
callback.invoke(err.getLocalizedMessage());
561565
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ void buildFormEntity(ReadableArray body) {
199199
String filename = map.getString("filename");
200200
// upload from storage
201201
if(data.startsWith(filePathPrefix)) {
202-
File file = new File(data.substring(filePathPrefix.length()));
202+
String orgPath = data.substring(filePathPrefix.length());
203+
File file = new File(RNFetchBlobFS.normalizePath(orgPath));
203204
form.addBinaryBody(name, file, ContentType.APPLICATION_OCTET_STREAM, filename);
204205
}
205206
// base64 embedded file content
@@ -228,7 +229,7 @@ void buildEntity(String body) {
228229
// upload from storage
229230
if(body.startsWith(filePathPrefix)) {
230231
String filePath = body.substring(filePathPrefix.length());
231-
entity = new FileEntity(new File(filePath));
232+
entity = new FileEntity(new File(RNFetchBlobFS.normalizePath(filePath)));
232233
}
233234
else {
234235
blob = Base64.decode(body, 0);

0 commit comments

Comments
 (0)