diff --git a/src/android/src/main/java/com/RNFetchBlob/Response/RNFetchBlobFileResp.java b/src/android/src/main/java/com/RNFetchBlob/Response/RNFetchBlobFileResp.java index fc2bd3307..bc9b3779c 100644 --- a/src/android/src/main/java/com/RNFetchBlob/Response/RNFetchBlobFileResp.java +++ b/src/android/src/main/java/com/RNFetchBlob/Response/RNFetchBlobFileResp.java @@ -46,6 +46,12 @@ public RNFetchBlobFileResp(ReactApplicationContext ctx, String taskId, ResponseB path = path.replace("?append=true", ""); mPath = path; File f = new File(path); + + File parent = f.getParentFile(); + if(!parent.exists() && !parent.mkdirs()){ + throw new IllegalStateException("Couldn't create dir: " + parent); + } + if(f.exists() == false) f.createNewFile(); ofStream = new FileOutputStream(new File(path), appendToExistingFile);