浏览代码

Add Android fs.readFile app provider URI support #287

Ben Hsieh 7 年前
父节点
当前提交
40fefd4b2e
共有 1 个文件被更改,包括 14 次插入1 次删除
  1. 14
    1
      android/src/main/java/com/RNFetchBlob/Utils/PathResolver.java

+ 14
- 1
android/src/main/java/com/RNFetchBlob/Utils/PathResolver.java 查看文件

@@ -59,6 +59,14 @@ public class PathResolver {
59 59
 
60 60
                 return getDataColumn(context, contentUri, selection, selectionArgs);
61 61
             }
62
+            else if ("content".equalsIgnoreCase(uri.getScheme())) {
63
+
64
+                // Return the remote address
65
+                if (isGooglePhotosUri(uri))
66
+                    return uri.getLastPathSegment();
67
+
68
+                return getDataColumn(context, uri, null, null);
69
+            }
62 70
         }
63 71
         // MediaStore (and general)
64 72
         else if ("content".equalsIgnoreCase(uri.getScheme())) {
@@ -103,7 +111,12 @@ public class PathResolver {
103 111
                 final int index = cursor.getColumnIndexOrThrow(column);
104 112
                 return cursor.getString(index);
105 113
             }
106
-        } finally {
114
+        }
115
+        catch (Exception ex) {
116
+            ex.printStackTrace();
117
+            return null;
118
+        }
119
+        finally {
107 120
             if (cursor != null)
108 121
                 cursor.close();
109 122
         }