@simplysm/capacitor-plugin-file-system 13.0.81 → 13.0.83

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/README.md +200 -0
  2. package/package.json +4 -5
package/README.md ADDED
@@ -0,0 +1,200 @@
1
+ # @simplysm/capacitor-plugin-file-system
2
+
3
+ Capacitor plugin for file system access across Android and web platforms.
4
+
5
+ - **Android 11+**: Full file system access via `MANAGE_EXTERNAL_STORAGE` permission
6
+ - **Android 10 and below**: `READ_EXTERNAL_STORAGE` / `WRITE_EXTERNAL_STORAGE` permissions
7
+ - **Browser**: IndexedDB-based virtual file system emulation
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @simplysm/capacitor-plugin-file-system
13
+ ```
14
+
15
+ ### Peer Dependencies
16
+
17
+ - `@capacitor/core` ^7.4.4
18
+
19
+ ## API
20
+
21
+ ### `FileSystem`
22
+
23
+ Abstract static class providing all file system operations.
24
+
25
+ ```typescript
26
+ import { FileSystem } from "@simplysm/capacitor-plugin-file-system";
27
+ ```
28
+
29
+ #### `FileSystem.checkPermissions()`
30
+
31
+ Check whether file system permissions are granted.
32
+
33
+ ```typescript
34
+ static async checkPermissions(): Promise<boolean>
35
+ ```
36
+
37
+ **Returns**: `true` if permissions are granted, `false` otherwise. On the web platform, always returns `true`.
38
+
39
+ #### `FileSystem.requestPermissions()`
40
+
41
+ Request file system permissions from the user.
42
+
43
+ ```typescript
44
+ static async requestPermissions(): Promise<void>
45
+ ```
46
+
47
+ - Android 11+: Navigates to the system settings page for the user to grant access.
48
+ - Android 10 and below: Shows the standard permission dialog.
49
+
50
+ #### `FileSystem.readdir(dirPath)`
51
+
52
+ Read the contents of a directory.
53
+
54
+ ```typescript
55
+ static async readdir(dirPath: string): Promise<FileInfo[]>
56
+ ```
57
+
58
+ | Parameter | Type | Description |
59
+ |-----------|------|-------------|
60
+ | `dirPath` | `string` | Absolute path to the directory |
61
+
62
+ **Returns**: Array of `FileInfo` objects.
63
+
64
+ #### `FileSystem.getStoragePath(type)`
65
+
66
+ Get the absolute path for a specific storage location.
67
+
68
+ ```typescript
69
+ static async getStoragePath(type: StorageType): Promise<string>
70
+ ```
71
+
72
+ | Parameter | Type | Description |
73
+ |-----------|------|-------------|
74
+ | `type` | `StorageType` | The storage location type |
75
+
76
+ **Returns**: Absolute path string for the requested storage location.
77
+
78
+ #### `FileSystem.getUri(filePath)`
79
+
80
+ Get a content URI for a file (via Android FileProvider). On the web platform, returns a Blob URL that must be released with `URL.revokeObjectURL()` after use.
81
+
82
+ ```typescript
83
+ static async getUri(filePath: string): Promise<string>
84
+ ```
85
+
86
+ | Parameter | Type | Description |
87
+ |-----------|------|-------------|
88
+ | `filePath` | `string` | Absolute path to the file |
89
+
90
+ **Returns**: URI string.
91
+
92
+ #### `FileSystem.writeFile(filePath, data)`
93
+
94
+ Write data to a file. Parent directories are created automatically.
95
+
96
+ ```typescript
97
+ static async writeFile(filePath: string, data: string | Bytes): Promise<void>
98
+ ```
99
+
100
+ | Parameter | Type | Description |
101
+ |-----------|------|-------------|
102
+ | `filePath` | `string` | Absolute path to the file |
103
+ | `data` | `string \| Bytes` | Content to write. Strings are written as UTF-8; `Bytes` (`Uint8Array`) is encoded as base64 for transfer. |
104
+
105
+ #### `FileSystem.readFile(filePath, encoding?)`
106
+
107
+ Read a file. Returns binary data by default, or a UTF-8 string when the encoding parameter is provided.
108
+
109
+ ```typescript
110
+ static async readFile(filePath: string): Promise<Bytes>
111
+ static async readFile(filePath: string, encoding: "utf8"): Promise<string>
112
+ ```
113
+
114
+ | Parameter | Type | Description |
115
+ |-----------|------|-------------|
116
+ | `filePath` | `string` | Absolute path to the file |
117
+ | `encoding` | `"utf8"` (optional) | If provided, returns a UTF-8 decoded string |
118
+
119
+ **Returns**: `Bytes` (binary) or `string` depending on the encoding parameter.
120
+
121
+ #### `FileSystem.remove(targetPath)`
122
+
123
+ Delete a file or directory. Directories are removed recursively.
124
+
125
+ ```typescript
126
+ static async remove(targetPath: string): Promise<void>
127
+ ```
128
+
129
+ | Parameter | Type | Description |
130
+ |-----------|------|-------------|
131
+ | `targetPath` | `string` | Absolute path to the file or directory |
132
+
133
+ #### `FileSystem.mkdir(targetPath)`
134
+
135
+ Create a directory. Missing parent directories are created recursively.
136
+
137
+ ```typescript
138
+ static async mkdir(targetPath: string): Promise<void>
139
+ ```
140
+
141
+ | Parameter | Type | Description |
142
+ |-----------|------|-------------|
143
+ | `targetPath` | `string` | Absolute path to the directory |
144
+
145
+ #### `FileSystem.exists(targetPath)`
146
+
147
+ Check whether a file or directory exists.
148
+
149
+ ```typescript
150
+ static async exists(targetPath: string): Promise<boolean>
151
+ ```
152
+
153
+ | Parameter | Type | Description |
154
+ |-----------|------|-------------|
155
+ | `targetPath` | `string` | Absolute path to check |
156
+
157
+ **Returns**: `true` if the path exists, `false` otherwise.
158
+
159
+ ## Types
160
+
161
+ ### `StorageType`
162
+
163
+ ```typescript
164
+ type StorageType =
165
+ | "external" // External storage root (Environment.getExternalStorageDirectory)
166
+ | "externalFiles" // App-specific external files directory
167
+ | "externalCache" // App-specific external cache directory
168
+ | "externalMedia" // App-specific external media directory
169
+ | "appData" // App data directory
170
+ | "appFiles" // App files directory
171
+ | "appCache"; // App cache directory
172
+ ```
173
+
174
+ ### `FileInfo`
175
+
176
+ ```typescript
177
+ interface FileInfo {
178
+ name: string; // File or directory name
179
+ isDirectory: boolean; // true if the entry is a directory
180
+ }
181
+ ```
182
+
183
+ ### `FileSystemPlugin`
184
+
185
+ Low-level Capacitor plugin interface. Use the `FileSystem` class instead for a simpler API.
186
+
187
+ ```typescript
188
+ interface FileSystemPlugin {
189
+ checkPermissions(): Promise<{ granted: boolean }>;
190
+ requestPermissions(): Promise<void>;
191
+ readdir(options: { path: string }): Promise<{ files: FileInfo[] }>;
192
+ getStoragePath(options: { type: StorageType }): Promise<{ path: string }>;
193
+ getUri(options: { path: string }): Promise<{ uri: string }>;
194
+ writeFile(options: { path: string; data: string; encoding?: "utf8" | "base64" }): Promise<void>;
195
+ readFile(options: { path: string; encoding?: "utf8" | "base64" }): Promise<{ data: string }>;
196
+ remove(options: { path: string }): Promise<void>;
197
+ mkdir(options: { path: string }): Promise<void>;
198
+ exists(options: { path: string }): Promise<{ exists: boolean }>;
199
+ }
200
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/capacitor-plugin-file-system",
3
- "version": "13.0.81",
3
+ "version": "13.0.83",
4
4
  "description": "Simplysm Package - Capacitor File System Plugin",
5
5
  "author": "simplysm",
6
6
  "license": "MIT",
@@ -15,12 +15,11 @@
15
15
  "files": [
16
16
  "dist",
17
17
  "src",
18
- "android",
19
- "docs"
18
+ "android"
20
19
  ],
21
20
  "dependencies": {
22
- "@simplysm/core-browser": "13.0.81",
23
- "@simplysm/core-common": "13.0.81"
21
+ "@simplysm/core-browser": "13.0.83",
22
+ "@simplysm/core-common": "13.0.83"
24
23
  },
25
24
  "devDependencies": {
26
25
  "@capacitor/core": "^7.6.0"