@simplysm/capacitor-plugin-file-system 13.0.95 → 13.0.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/README.md +0 -172
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/capacitor-plugin-file-system",
3
- "version": "13.0.95",
3
+ "version": "13.0.97",
4
4
  "description": "Simplysm Package - Capacitor File System Plugin",
5
5
  "author": "simplysm",
6
6
  "license": "MIT",
@@ -18,8 +18,8 @@
18
18
  "android"
19
19
  ],
20
20
  "dependencies": {
21
- "@simplysm/core-browser": "13.0.95",
22
- "@simplysm/core-common": "13.0.95"
21
+ "@simplysm/core-browser": "13.0.97",
22
+ "@simplysm/core-common": "13.0.97"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@capacitor/core": "^7.6.0"
package/README.md DELETED
@@ -1,172 +0,0 @@
1
- # @simplysm/capacitor-plugin-file-system
2
-
3
- Capacitor 파일시스템 플러그인. Android 네이티브 파일시스템 접근과 Web IndexedDB 기반 가상 파일시스템을 제공한다.
4
-
5
- ## 설치
6
-
7
- ```bash
8
- npm install @simplysm/capacitor-plugin-file-system
9
- ```
10
-
11
- **의존성:** `@simplysm/core-common` (Bytes, bytes 유틸), `@simplysm/core-browser` (IndexedDbStore, IndexedDbVirtualFs)
12
- **Peer:** `@capacitor/core` ^7.4.4
13
-
14
- ## Export 목록
15
-
16
- ```typescript
17
- // index.ts
18
- export { FileSystem } from "./FileSystem";
19
- export type { FileSystemPlugin, FileInfo, StorageType } from "./FileSystemPlugin";
20
- ```
21
-
22
- ## 주요 사용법
23
-
24
- ### 권한 관리
25
-
26
- ```typescript
27
- import { FileSystem } from "@simplysm/capacitor-plugin-file-system";
28
-
29
- const granted = await FileSystem.checkPermissions(); // boolean
30
- if (!granted) {
31
- await FileSystem.requestPermissions();
32
- // Android 11+: MANAGE_EXTERNAL_STORAGE 설정 화면 이동
33
- // Android 10-: READ/WRITE_EXTERNAL_STORAGE 권한 다이얼로그
34
- }
35
- ```
36
-
37
- ### 파일 읽기/쓰기
38
-
39
- ```typescript
40
- import type { Bytes } from "@simplysm/core-common";
41
-
42
- // 텍스트 파일 쓰기
43
- await FileSystem.writeFile("/storage/emulated/0/test.txt", "Hello World");
44
-
45
- // 바이너리 파일 쓰기 (Bytes = Uint8Array)
46
- const data: Bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
47
- await FileSystem.writeFile("/storage/emulated/0/data.bin", data);
48
-
49
- // 텍스트 읽기
50
- const text: string = await FileSystem.readFile("/path/to/file.txt", "utf8");
51
-
52
- // 바이너리 읽기 (기본값, Bytes 반환)
53
- const bytes: Bytes = await FileSystem.readFile("/path/to/file.bin");
54
- ```
55
-
56
- `writeFile`은 내부적으로 string이면 utf8, Bytes이면 base64로 인코딩하여 네이티브에 전달한다.
57
-
58
- ### 디렉토리 조작
59
-
60
- ```typescript
61
- // 디렉토리 생성 (재귀)
62
- await FileSystem.mkdir("/storage/emulated/0/myapp/data");
63
-
64
- // 디렉토리 목록 조회
65
- const files = await FileSystem.readdir("/storage/emulated/0/myapp");
66
- // FileInfo[] = [{ name: "data", isDirectory: true }, { name: "config.json", isDirectory: false }]
67
-
68
- // 파일/디렉토리 삭제 (재귀)
69
- await FileSystem.remove("/storage/emulated/0/myapp/temp");
70
-
71
- // 존재 여부 확인
72
- const exists = await FileSystem.exists("/storage/emulated/0/myapp"); // boolean
73
- ```
74
-
75
- ### 스토리지 경로 조회
76
-
77
- ```typescript
78
- const path = await FileSystem.getStoragePath("external"); // string
79
- ```
80
-
81
- | 타입 | Android 경로 | 설명 |
82
- |------|-------------|------|
83
- | `"external"` | `Environment.getExternalStorageDirectory()` | 외부 스토리지 루트 |
84
- | `"externalFiles"` | `getExternalFilesDir(null)` | 앱 전용 외부 파일 |
85
- | `"externalCache"` | `getExternalCacheDir()` | 앱 전용 외부 캐시 |
86
- | `"externalMedia"` | `getExternalMediaDirs()[0]` | 앱 전용 미디어 |
87
- | `"appData"` | `getApplicationInfo().dataDir` | 앱 데이터 디렉토리 |
88
- | `"appFiles"` | `getFilesDir()` | 앱 파일 디렉토리 |
89
- | `"appCache"` | `getCacheDir()` | 앱 캐시 디렉토리 |
90
-
91
- Web 환경에서는 `/webfs/{type}` 가상 경로를 반환한다.
92
-
93
- ### FileProvider URI
94
-
95
- 파일의 `content://` URI를 얻는다. APK 설치 등 인텐트에 파일을 전달할 때 사용한다.
96
-
97
- ```typescript
98
- const uri = await FileSystem.getUri("/path/to/file.apk");
99
- // content://{applicationId}.filesystem.provider/...
100
- ```
101
-
102
- ## API 레퍼런스
103
-
104
- ### `FileSystem` (abstract class, static 메서드)
105
-
106
- | 메서드 | 시그니처 | 설명 |
107
- |--------|----------|------|
108
- | `checkPermissions` | `() => Promise<boolean>` | 파일시스템 권한 확인 |
109
- | `requestPermissions` | `() => Promise<void>` | 권한 요청 |
110
- | `readdir` | `(dirPath: string) => Promise<FileInfo[]>` | 디렉토리 목록 |
111
- | `getStoragePath` | `(type: StorageType) => Promise<string>` | 스토리지 경로 조회 |
112
- | `getUri` | `(filePath: string) => Promise<string>` | FileProvider URI |
113
- | `writeFile` | `(filePath: string, data: string \| Bytes) => Promise<void>` | 파일 쓰기 |
114
- | `readFile` | `(filePath: string) => Promise<Bytes>` | 바이너리 읽기 |
115
- | `readFile` | `(filePath: string, encoding: "utf8") => Promise<string>` | 텍스트 읽기 |
116
- | `remove` | `(targetPath: string) => Promise<void>` | 재귀 삭제 |
117
- | `mkdir` | `(targetPath: string) => Promise<void>` | 재귀 생성 |
118
- | `exists` | `(targetPath: string) => Promise<boolean>` | 존재 여부 확인 |
119
-
120
- ### `StorageType` (type alias)
121
-
122
- ```typescript
123
- type StorageType =
124
- | "external"
125
- | "externalFiles"
126
- | "externalCache"
127
- | "externalMedia"
128
- | "appData"
129
- | "appFiles"
130
- | "appCache";
131
- ```
132
-
133
- ### `FileInfo` (interface)
134
-
135
- ```typescript
136
- interface FileInfo {
137
- name: string; // 파일/디렉토리 이름
138
- isDirectory: boolean;
139
- }
140
- ```
141
-
142
- ## 플랫폼 지원
143
-
144
- | 기능 | Android | Web |
145
- |------|---------|-----|
146
- | 파일 읽기/쓰기 | 네이티브 파일시스템 (base64/utf8) | IndexedDB 가상 파일시스템 |
147
- | 디렉토리 | `java.io.File` API | IndexedDB 기반 가상 경로 |
148
- | 스토리지 경로 | Android 스토리지 API | `/webfs/{type}` 가상 경로 |
149
- | FileProvider | `content://` URI 생성 | Blob URL (`URL.createObjectURL`) |
150
- | 권한 | MANAGE_EXTERNAL_STORAGE / READ+WRITE | 항상 granted |
151
-
152
- ## Android 네이티브 구현
153
-
154
- - **패키지:** `kr.co.simplysm.capacitor.filesystem`
155
- - **플러그인명:** `FileSystem`
156
- - **FileProvider authority:** `${applicationId}.filesystem.provider`
157
- - **FileProvider paths:** external, external_files, external_cache, files, cache (모두 root `.`)
158
- - **AndroidManifest 권한:**
159
- - `READ_EXTERNAL_STORAGE` (maxSdkVersion=32)
160
- - `WRITE_EXTERNAL_STORAGE` (maxSdkVersion=29)
161
- - `MANAGE_EXTERNAL_STORAGE`
162
- - `writeFile`: 부모 디렉토리 자동 생성 (`mkdirs`), BufferedOutputStream 사용
163
- - `readFile`: BufferedInputStream + ByteArrayOutputStream (8KB 버퍼)
164
-
165
- ## Web 구현 상세
166
-
167
- `FileSystemWeb`은 `VirtualFileSystem` 클래스를 사용하며, 내부적으로 `IndexedDbStore`와 `IndexedDbVirtualFs`(`@simplysm/core-browser`)를 활용한다.
168
-
169
- - **IndexedDB 이름:** `capacitor_web_virtual_fs`
170
- - **스토어:** `entries` (keyPath: `path`)
171
- - `getUri`: Blob URL 반환. 사용 후 `URL.revokeObjectURL(uri)` 호출 필요 (메모리 누수 방지)
172
- - 암묵적 디렉토리 처리: 파일 경로만 저장되어 있어도 중간 경로를 디렉토리로 인식