@simplysm/capacitor-plugin-file-system 13.0.97 → 13.0.99
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.
- package/README.md +98 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @simplysm/capacitor-plugin-file-system
|
|
2
|
+
|
|
3
|
+
Simplysm Package - Capacitor File System Plugin. Provides file system access for Android (MANAGE_EXTERNAL_STORAGE on Android 11+) with IndexedDB-based browser emulation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @simplysm/capacitor-plugin-file-system
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API Overview
|
|
12
|
+
|
|
13
|
+
### File System
|
|
14
|
+
|
|
15
|
+
| API | Type | Description |
|
|
16
|
+
|-----|------|-------------|
|
|
17
|
+
| `FileSystem` | class | File system access plugin (static methods) |
|
|
18
|
+
| `FileSystemPlugin` | interface | Low-level Capacitor plugin interface for file system |
|
|
19
|
+
| `StorageType` | type | Storage location type |
|
|
20
|
+
| `FileInfo` | interface | File/directory entry information |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
### `StorageType`
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
type StorageType =
|
|
28
|
+
| "external" // External storage root (Environment.getExternalStorageDirectory)
|
|
29
|
+
| "externalFiles" // App-specific external files directory
|
|
30
|
+
| "externalCache" // App-specific external cache directory
|
|
31
|
+
| "externalMedia" // App-specific external media directory
|
|
32
|
+
| "appData" // App data directory
|
|
33
|
+
| "appFiles" // App files directory
|
|
34
|
+
| "appCache"; // App cache directory
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### `FileInfo`
|
|
38
|
+
|
|
39
|
+
| Field | Type | Description |
|
|
40
|
+
|-------|------|-------------|
|
|
41
|
+
| `name` | `string` | File or directory name |
|
|
42
|
+
| `isDirectory` | `boolean` | Whether the entry is a directory |
|
|
43
|
+
|
|
44
|
+
### `FileSystemPlugin`
|
|
45
|
+
|
|
46
|
+
| Method | Signature | Description |
|
|
47
|
+
|--------|-----------|-------------|
|
|
48
|
+
| `checkPermissions` | `() => Promise<{ granted: boolean }>` | Check file system permission |
|
|
49
|
+
| `requestPermissions` | `() => Promise<void>` | Request file system permission |
|
|
50
|
+
| `readdir` | `(options: { path: string }) => Promise<{ files: FileInfo[] }>` | Read directory contents |
|
|
51
|
+
| `getStoragePath` | `(options: { type: StorageType }) => Promise<{ path: string }>` | Get storage path by type |
|
|
52
|
+
| `getUri` | `(options: { path: string }) => Promise<{ uri: string }>` | Get FileProvider URI |
|
|
53
|
+
| `writeFile` | `(options: { path: string; data: string; encoding?: "utf8" \| "base64" }) => Promise<void>` | Write file |
|
|
54
|
+
| `readFile` | `(options: { path: string; encoding?: "utf8" \| "base64" }) => Promise<{ data: string }>` | Read file |
|
|
55
|
+
| `remove` | `(options: { path: string }) => Promise<void>` | Delete file/directory |
|
|
56
|
+
| `mkdir` | `(options: { path: string }) => Promise<void>` | Create directory |
|
|
57
|
+
| `exists` | `(options: { path: string }) => Promise<{ exists: boolean }>` | Check existence |
|
|
58
|
+
|
|
59
|
+
### `FileSystem`
|
|
60
|
+
|
|
61
|
+
Abstract class with static methods for file system access. Android 11+ uses MANAGE_EXTERNAL_STORAGE; Android 10- uses READ/WRITE_EXTERNAL_STORAGE; browser uses IndexedDB emulation.
|
|
62
|
+
|
|
63
|
+
| Method | Signature | Description |
|
|
64
|
+
|--------|-----------|-------------|
|
|
65
|
+
| `checkPermissions` | `() => Promise<boolean>` | Check permission |
|
|
66
|
+
| `requestPermissions` | `() => Promise<void>` | Request permission (Android 11+: settings, Android 10-: dialog) |
|
|
67
|
+
| `readdir` | `(dirPath: string) => Promise<FileInfo[]>` | Read directory |
|
|
68
|
+
| `getStoragePath` | `(type: StorageType) => Promise<string>` | Get storage path |
|
|
69
|
+
| `getUri` | `(filePath: string) => Promise<string>` | Get FileProvider URI |
|
|
70
|
+
| `writeFile` | `(filePath: string, data: string \| Bytes) => Promise<void>` | Write file (string or Uint8Array) |
|
|
71
|
+
| `readFile` | `(filePath: string) => Promise<Bytes>` | Read file as Bytes |
|
|
72
|
+
| `readFile` | `(filePath: string, encoding: "utf8") => Promise<string>` | Read file as UTF-8 string |
|
|
73
|
+
| `remove` | `(targetPath: string) => Promise<void>` | Delete file/directory (recursive) |
|
|
74
|
+
| `mkdir` | `(targetPath: string) => Promise<void>` | Create directory (recursive) |
|
|
75
|
+
| `exists` | `(targetPath: string) => Promise<boolean>` | Check existence |
|
|
76
|
+
|
|
77
|
+
## Usage Examples
|
|
78
|
+
|
|
79
|
+
### Read and write files
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { FileSystem } from "@simplysm/capacitor-plugin-file-system";
|
|
83
|
+
|
|
84
|
+
// Check and request permissions
|
|
85
|
+
if (!(await FileSystem.checkPermissions())) {
|
|
86
|
+
await FileSystem.requestPermissions();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Get storage path and write a file
|
|
90
|
+
const storagePath = await FileSystem.getStoragePath("appFiles");
|
|
91
|
+
await FileSystem.writeFile(`${storagePath}/data.txt`, "Hello, world!");
|
|
92
|
+
|
|
93
|
+
// Read it back
|
|
94
|
+
const content = await FileSystem.readFile(`${storagePath}/data.txt`, "utf8");
|
|
95
|
+
|
|
96
|
+
// List directory contents
|
|
97
|
+
const files = await FileSystem.readdir(storagePath);
|
|
98
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/capacitor-plugin-file-system",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.99",
|
|
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-
|
|
22
|
-
"@simplysm/core-
|
|
21
|
+
"@simplysm/core-common": "13.0.99",
|
|
22
|
+
"@simplysm/core-browser": "13.0.99"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@capacitor/core": "^7.6.0"
|