|
@@ -1,5 +1,7 @@
|
1
|
1
|
package com.RNFetchBlob;
|
2
|
2
|
|
|
3
|
+import android.content.pm.PackageInfo;
|
|
4
|
+import android.content.pm.PackageManager;
|
3
|
5
|
import android.content.res.AssetFileDescriptor;
|
4
|
6
|
import android.media.MediaScannerConnection;
|
5
|
7
|
import android.net.Uri;
|
|
@@ -184,6 +186,18 @@ public class RNFetchBlobFS {
|
184
|
186
|
*/
|
185
|
187
|
static public Map<String, Object> getSystemfolders(ReactApplicationContext ctx) {
|
186
|
188
|
Map<String, Object> res = new HashMap<>();
|
|
189
|
+
|
|
190
|
+ PackageManager m = ctx.getPackageManager();
|
|
191
|
+ String s = ctx.getPackageName();
|
|
192
|
+ PackageInfo p = null;
|
|
193
|
+
|
|
194
|
+ try {
|
|
195
|
+ p = m.getPackageInfo(s, 0);
|
|
196
|
+ s = p.applicationInfo.dataDir;
|
|
197
|
+ res.put("DocumentDir", s);
|
|
198
|
+ } catch (PackageManager.NameNotFoundException e) {
|
|
199
|
+ e.printStackTrace();
|
|
200
|
+ }
|
187
|
201
|
res.put("DocumentDir", ctx.getFilesDir().getAbsolutePath());
|
188
|
202
|
res.put("CacheDir", ctx.getCacheDir().getAbsolutePath());
|
189
|
203
|
res.put("DCIMDir", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath());
|
|
@@ -782,14 +796,14 @@ public class RNFetchBlobFS {
|
782
|
796
|
* @param event Event name, `data`, `end`, `error`, etc.
|
783
|
797
|
* @param data Event data
|
784
|
798
|
*/
|
785
|
|
- void emitStreamEvent(String streamName, String event, String data) {
|
|
799
|
+ private void emitStreamEvent(String streamName, String event, String data) {
|
786
|
800
|
WritableMap eventData = Arguments.createMap();
|
787
|
801
|
eventData.putString("event", event);
|
788
|
802
|
eventData.putString("detail", data);
|
789
|
803
|
this.emitter.emit(streamName, eventData);
|
790
|
804
|
}
|
791
|
805
|
|
792
|
|
- void emitStreamEvent(String streamName, String event, WritableArray data) {
|
|
806
|
+ private void emitStreamEvent(String streamName, String event, WritableArray data) {
|
793
|
807
|
WritableMap eventData = Arguments.createMap();
|
794
|
808
|
eventData.putString("event", event);
|
795
|
809
|
eventData.putArray("detail", data);
|
|
@@ -838,13 +852,13 @@ public class RNFetchBlobFS {
|
838
|
852
|
|
839
|
853
|
}
|
840
|
854
|
|
841
|
|
- public static boolean isAsset(String path) {
|
|
855
|
+ static boolean isAsset(String path) {
|
842
|
856
|
if(path != null)
|
843
|
857
|
return path.startsWith(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET);
|
844
|
858
|
return false;
|
845
|
859
|
}
|
846
|
860
|
|
847
|
|
- public static String normalizePath(String path) {
|
|
861
|
+ static String normalizePath(String path) {
|
848
|
862
|
if(path == null)
|
849
|
863
|
return null;
|
850
|
864
|
Uri uri = Uri.parse(path);
|