Browse Source

Add Android fs.readFile app provider URI support #287

Ben Hsieh 7 years ago
parent
commit
40fefd4b2e
1 changed files with 14 additions and 1 deletions
  1. 14
    1
      android/src/main/java/com/RNFetchBlob/Utils/PathResolver.java

+ 14
- 1
android/src/main/java/com/RNFetchBlob/Utils/PathResolver.java View File

59
 
59
 
60
                 return getDataColumn(context, contentUri, selection, selectionArgs);
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
         // MediaStore (and general)
71
         // MediaStore (and general)
64
         else if ("content".equalsIgnoreCase(uri.getScheme())) {
72
         else if ("content".equalsIgnoreCase(uri.getScheme())) {
103
                 final int index = cursor.getColumnIndexOrThrow(column);
111
                 final int index = cursor.getColumnIndexOrThrow(column);
104
                 return cursor.getString(index);
112
                 return cursor.getString(index);
105
             }
113
             }
106
-        } finally {
114
+        }
115
+        catch (Exception ex) {
116
+            ex.printStackTrace();
117
+            return null;
118
+        }
119
+        finally {
107
             if (cursor != null)
120
             if (cursor != null)
108
                 cursor.close();
121
                 cursor.close();
109
         }
122
         }