소스 검색

Create missing directories on Android

Chris Sloey 8 년 전
부모
커밋
9d5a5d9696
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6
    0
      src/android/src/main/java/com/RNFetchBlob/Response/RNFetchBlobFileResp.java

+ 6
- 0
src/android/src/main/java/com/RNFetchBlob/Response/RNFetchBlobFileResp.java 파일 보기

@@ -46,6 +46,12 @@ public class RNFetchBlobFileResp extends ResponseBody {
46 46
             path = path.replace("?append=true", "");
47 47
             mPath = path;
48 48
             File f = new File(path);
49
+
50
+            File parent = f.getParentFile();
51
+            if(!parent.exists() && !parent.mkdirs()){
52
+                throw new IllegalStateException("Couldn't create dir: " + parent);
53
+            }
54
+
49 55
             if(f.exists() == false)
50 56
                 f.createNewFile();
51 57
             ofStream = new FileOutputStream(new File(path), appendToExistingFile);