File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
android/src/main/java/com/rnfs Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -115,11 +115,15 @@ private InputStream getInputStream(String filepath) throws IORejectionException
115
115
return stream ;
116
116
}
117
117
118
+ private String getWriteAccessByAPILevel () {
119
+ return android .os .Build .VERSION .SDK_INT <= android .os .Build .VERSION_CODES .P ? "w" : "rwt" ;
120
+ }
121
+
118
122
private OutputStream getOutputStream (String filepath , boolean append ) throws IORejectionException {
119
123
Uri uri = getFileUri (filepath , false );
120
124
OutputStream stream ;
121
125
try {
122
- stream = reactContext .getContentResolver ().openOutputStream (uri , append ? "wa" : "w" );
126
+ stream = reactContext .getContentResolver ().openOutputStream (uri , append ? "wa" : getWriteAccessByAPILevel () );
123
127
} catch (FileNotFoundException ex ) {
124
128
throw new IORejectionException ("ENOENT" , "ENOENT: " + ex .getMessage () + ", open '" + filepath + "'" );
125
129
}
You can’t perform that action at this time.
0 commit comments