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

Commit be00a24

Browse files
committed
Merge branch '0.10.6' of github.com:wkh237/react-native-fetch-blob into 0.10.6
2 parents a6a8516 + 93509a7 commit be00a24

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

CONTRIBUTORS.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
22
Andreas Amsenius <[email protected]>
3+
Andrew Jack <[email protected]>
34
Arthur Ouaki <[email protected]>
45
Binur Konarbai <[email protected]>
6+
57
Chris Sloey <[email protected]>
68
Corentin Smith <[email protected]>
79
Dmitry Petukhov <[email protected]>
810
Dombi Soma Kristóf <[email protected]>
911
Erik Smartt <[email protected]>
1012
Evgeniy Baraniuk <[email protected]>
1113
Frank van der Hoek <[email protected]>
14+
Guy Blank <[email protected]>
15+
Jon San Miguel <[email protected]>
1216
Juan B. Rodriguez <[email protected]>
1317
1418
Martin Giachetti <[email protected]>
19+
Max Gurela <[email protected]>
1520
Mike Monteith <[email protected]>
1621
Naoki AINOYA <[email protected]>
1722
Nguyen Cao Nhat Linh <[email protected]>
23+
Nick Pomfret <[email protected]>
24+
1825
Petter Hesselberg <[email protected]>
26+
Reza Ghorbani <[email protected]>
27+
Steve Liles <[email protected]>
1928
Tim Suchanek <[email protected]>
29+
Yonsh Lin <[email protected]>
30+
2031
2132
francisco-sanchez-molina <[email protected]>
33+
gferreyra91 <[email protected]>
2234
2335
kejinliang <[email protected]>
2436
pedramsaleh <[email protected]>

android/src/main/java/com/RNFetchBlob/Utils/PathResolver.java

+40
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
import android.provider.MediaStore;
99
import android.content.ContentUris;
1010
import android.os.Environment;
11+
import android.content.ContentResolver;
12+
import com.RNFetchBlob.RNFetchBlobUtils;
13+
import java.io.File;
14+
import java.io.InputStream;
15+
import java.io.FileOutputStream;
1116

1217
public class PathResolver {
1318
public static String getRealPathFromURI(final Context context, final Uri uri) {
@@ -59,6 +64,29 @@ else if (isMediaDocument(uri)) {
5964

6065
return getDataColumn(context, contentUri, selection, selectionArgs);
6166
}
67+
// Other Providers
68+
else {
69+
try {
70+
InputStream attachment = context.getContentResolver().openInputStream(uri);
71+
if (attachment != null) {
72+
String filename = getContentName(context.getContentResolver(), uri);
73+
if (filename != null) {
74+
File file = new File(context.getCacheDir(), filename);
75+
FileOutputStream tmp = new FileOutputStream(file);
76+
byte[] buffer = new byte[1024];
77+
while (attachment.read(buffer) > 0) {
78+
tmp.write(buffer);
79+
}
80+
tmp.close();
81+
attachment.close();
82+
return file.getAbsolutePath();
83+
}
84+
}
85+
} catch (Exception e) {
86+
RNFetchBlobUtils.emitWarningEvent(e.toString());
87+
return null;
88+
}
89+
}
6290
}
6391
// MediaStore (and general)
6492
else if ("content".equalsIgnoreCase(uri.getScheme())) {
@@ -77,6 +105,18 @@ else if ("file".equalsIgnoreCase(uri.getScheme())) {
77105
return null;
78106
}
79107

108+
private static String getContentName(ContentResolver resolver, Uri uri) {
109+
Cursor cursor = resolver.query(uri, null, null, null, null);
110+
cursor.moveToFirst();
111+
int nameIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
112+
if (nameIndex >= 0) {
113+
String name = cursor.getString(nameIndex);
114+
cursor.close();
115+
return name;
116+
}
117+
return null;
118+
}
119+
80120
/**
81121
* Get the value of the data column for this Uri. This is useful for
82122
* MediaStore Uris, and other file-based ContentProviders.

index.js

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ const RNFetchBlob = NativeModules.RNFetchBlob
5050
// their .expire event
5151
if(Platform.OS === 'ios') {
5252
AppState.addEventListener('change', (e) => {
53-
console.log('app state changed', e)
5453
if(e === 'active')
5554
RNFetchBlob.emitExpiredEvent(()=>{})
5655
})

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"author": "wkh237 <[email protected]>",
3333
"license": "MIT",
3434
"contributors": [
35+
3536
""
3637
]
37-
}
38+
}

0 commit comments

Comments
 (0)