Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

Commit

Permalink
Fix writeToFile with appending for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
hnq90 committed Jul 4, 2017
1 parent 19b94e8 commit d7bbe02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Expand Up @@ -65,14 +65,14 @@ private void createDirectories(File destination) {
holdingFolder.mkdirs();
}

public void writeToFile(String relativePath, String content, Storage storage) throws IOException {
public void writeToFile(String relativePath, String content, boolean isAppend, Storage storage) throws IOException {
String baseDir = baseDirForStorage(storage);
File destination = new File(baseDir + "/" + relativePath);
createDirectories(destination);

OutputStreamWriter output = null;
try {
output = new OutputStreamWriter(new FileOutputStream(destination));
output = new OutputStreamWriter(new FileOutputStream(destination, isAppend));
output.write(content);
} finally {
try {
Expand Down Expand Up @@ -127,9 +127,9 @@ public boolean deleteFileOrDirectory(String relativePath, Storage storage) {
}

@ReactMethod
public void writeToFile(String relativePath, String content, String storage, Promise promise) {
public void writeToFile(String relativePath, String content, boolean isAppend, String storage, Promise promise) {
try {
writeToFile(relativePath, content, Storage.valueOf(storage));
writeToFile(relativePath, content, isAppend, Storage.valueOf(storage));
promise.resolve(true);
} catch (IOException e) {
promise.reject("ERROR", e.getMessage());
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"name": "react-native-filesystem-v1",
"description": "Simple file system API for iOS & Android & Windows.",
"author": "Ben Wixen <benwixen@gmail.com>, HuyNQ <huy@huynq.net>",
"version": "0.10.9",
"version": "0.10.10",
"main": "modules/FileSystem.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down

0 comments on commit d7bbe02

Please sign in to comment.