Skip to content

Commit

Permalink
Merge pull request #890 from egealpay/overwrite-fix-android-10
Browse files Browse the repository at this point in the history
Fix: Overwrite bug on Android 10
  • Loading branch information
itinance authored Oct 13, 2021
2 parents 36d8ec5 + b7c7bf0 commit 146e7fb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion android/src/main/java/com/rnfs/RNFSManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,15 @@ private InputStream getInputStream(String filepath) throws IORejectionException
return stream;
}

private String getWriteAccessByAPILevel() {
return android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.P ? "w" : "rwt";
}

private OutputStream getOutputStream(String filepath, boolean append) throws IORejectionException {
Uri uri = getFileUri(filepath, false);
OutputStream stream;
try {
stream = reactContext.getContentResolver().openOutputStream(uri, append ? "wa" : "w");
stream = reactContext.getContentResolver().openOutputStream(uri, append ? "wa" : getWriteAccessByAPILevel());
} catch (FileNotFoundException ex) {
throw new IORejectionException("ENOENT", "ENOENT: " + ex.getMessage() + ", open '" + filepath + "'");
}
Expand Down

0 comments on commit 146e7fb

Please sign in to comment.