@capacitor/filesystem 1.1.0 → 4.0.0-beta.0
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/CHANGELOG.md +43 -0
- package/CapacitorFilesystem.podspec +1 -1
- package/README.md +32 -11
- package/android/build.gradle +9 -10
- package/android/src/main/java/com/capacitorjs/plugins/filesystem/Filesystem.java +7 -6
- package/android/src/main/java/com/capacitorjs/plugins/filesystem/FilesystemPlugin.java +39 -4
- package/dist/docs.json +106 -6
- package/dist/esm/definitions.d.ts +51 -5
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -2
- package/dist/esm/web.js +46 -13
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +46 -13
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +46 -13
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Filesystem.swift +9 -0
- package/ios/Plugin/FilesystemPlugin.swift +26 -6
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,49 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 4.0.0-beta.0 (2022-06-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **filesystem:** Prevent android crash on invalid base64 write ([#937](https://github.com/ionic-team/capacitor-plugins/issues/937)) ([1af0bfe](https://github.com/ionic-team/capacitor-plugins/commit/1af0bfe24d2a36bc2949fe52866131c3327b321e))
|
|
12
|
+
* **filesystem:** Throw errors instead of strings ([#746](https://github.com/ionic-team/capacitor-plugins/issues/746)) ([af4b875](https://github.com/ionic-team/capacitor-plugins/commit/af4b8750be512b869af07bcf96c1602eedc6758e))
|
|
13
|
+
* **filesystem:** web appendFile with base64 data ([#928](https://github.com/ionic-team/capacitor-plugins/issues/928)) ([80253cf](https://github.com/ionic-team/capacitor-plugins/commit/80253cf2652bf7fa9c07933989cbdffeadd52a27))
|
|
14
|
+
* correct addListeners links ([#655](https://github.com/ionic-team/capacitor-plugins/issues/655)) ([f9871e7](https://github.com/ionic-team/capacitor-plugins/commit/f9871e7bd53478addb21155e148829f550c0e457))
|
|
15
|
+
* inline source code in esm map files ([#760](https://github.com/ionic-team/capacitor-plugins/issues/760)) ([a960489](https://github.com/ionic-team/capacitor-plugins/commit/a960489a19db0182b90d187a50deff9dfbe51038))
|
|
16
|
+
* remove postpublish scripts ([#656](https://github.com/ionic-team/capacitor-plugins/issues/656)) ([ed6ac49](https://github.com/ionic-team/capacitor-plugins/commit/ed6ac499ebf4a47525071ccbfc36c27503e11f60))
|
|
17
|
+
* **android:** permissions use "publicStorage" as alias ([#202](https://github.com/ionic-team/capacitor-plugins/issues/202)) ([2dfc7a3](https://github.com/ionic-team/capacitor-plugins/commit/2dfc7a3261a4f98871a86fe6d47fab084a2d1deb))
|
|
18
|
+
* **android:** support writing files without scheme ([#241](https://github.com/ionic-team/capacitor-plugins/issues/241)) ([4285cb1](https://github.com/ionic-team/capacitor-plugins/commit/4285cb1d37ec3361e7ec4da4786502693b04d478))
|
|
19
|
+
* **filesystem:** allow copy if from is not parent of to ([#546](https://github.com/ionic-team/capacitor-plugins/issues/546)) ([a70414e](https://github.com/ionic-team/capacitor-plugins/commit/a70414e79189579ff1a0b5c2a90d12491f5c23cf))
|
|
20
|
+
* **filesystem:** Append doesn't resolve on iOS ([#305](https://github.com/ionic-team/capacitor-plugins/issues/305)) ([98e91cd](https://github.com/ionic-team/capacitor-plugins/commit/98e91cd745fb12bf46f99233bb527f147dbba58b))
|
|
21
|
+
* **filesystem:** Convert stat ctime/mtime timestamp to milliseconds ([#321](https://github.com/ionic-team/capacitor-plugins/issues/321)) ([d978986](https://github.com/ionic-team/capacitor-plugins/commit/d97898662d0ba037e5f8448990a91de5ec6a4234))
|
|
22
|
+
* **filesystem:** copy doesn't resolve on Android ([#233](https://github.com/ionic-team/capacitor-plugins/issues/233)) ([17cbf3b](https://github.com/ionic-team/capacitor-plugins/commit/17cbf3b0ada97f1279fba32b551c380c0e669406))
|
|
23
|
+
* **filesystem:** is not requesting permission on public directories ([#246](https://github.com/ionic-team/capacitor-plugins/issues/246)) ([aa897ab](https://github.com/ionic-team/capacitor-plugins/commit/aa897ab4269e34cd5d762ed645030054ddda7dd6))
|
|
24
|
+
* **filesystem:** Make ctime optional ([#373](https://github.com/ionic-team/capacitor-plugins/issues/373)) ([e3c6212](https://github.com/ionic-team/capacitor-plugins/commit/e3c6212b94c75cf747a8768af5056963683953b2))
|
|
25
|
+
* **filesystem:** rmdir doesn't resolve on iOS ([#239](https://github.com/ionic-team/capacitor-plugins/issues/239)) ([7ca538b](https://github.com/ionic-team/capacitor-plugins/commit/7ca538bb47e2e00080eadfe8d875323c1e198cb2))
|
|
26
|
+
* add es2017 lib to tsconfig ([#180](https://github.com/ionic-team/capacitor-plugins/issues/180)) ([2c3776c](https://github.com/ionic-team/capacitor-plugins/commit/2c3776c38ca025c5ee965dec10ccf1cdb6c02e2f))
|
|
27
|
+
* support deprecated types from Capacitor 2 ([#139](https://github.com/ionic-team/capacitor-plugins/issues/139)) ([2d7127a](https://github.com/ionic-team/capacitor-plugins/commit/2d7127a488e26f0287951921a6db47c49d817336))
|
|
28
|
+
* **filesystem:** Use PermissionState from @capacitor/core ([#148](https://github.com/ionic-team/capacitor-plugins/issues/148)) ([5ce3c5d](https://github.com/ionic-team/capacitor-plugins/commit/5ce3c5d491a35b8771661f3e4eb98aac6df15911))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* set targetSDK default value to 32 ([#970](https://github.com/ionic-team/capacitor-plugins/issues/970)) ([fa70d96](https://github.com/ionic-team/capacitor-plugins/commit/fa70d96f141af751aae53ceb5642c46b204f5958))
|
|
34
|
+
* **filesystem:** Make readDir return files information ([#949](https://github.com/ionic-team/capacitor-plugins/issues/949)) ([0a9f43d](https://github.com/ionic-team/capacitor-plugins/commit/0a9f43dffd3815f600c35ed4528c017644fdb55e))
|
|
35
|
+
* **filesystem:** Return path of copied file ([#931](https://github.com/ionic-team/capacitor-plugins/issues/931)) ([310f583](https://github.com/ionic-team/capacitor-plugins/commit/310f583ccec58730ab8046a1618782c950c60656))
|
|
36
|
+
* add commonjs output format ([#179](https://github.com/ionic-team/capacitor-plugins/issues/179)) ([8e9e098](https://github.com/ionic-team/capacitor-plugins/commit/8e9e09862064b3f6771d7facbc4008e995d9b463))
|
|
37
|
+
* Filesystem plugin ([#19](https://github.com/ionic-team/capacitor-plugins/issues/19)) ([3b86a4a](https://github.com/ionic-team/capacitor-plugins/commit/3b86a4a972e00eaed1d078bfcc69af6136222dc4))
|
|
38
|
+
* set targetSDK default value to 31 ([#824](https://github.com/ionic-team/capacitor-plugins/issues/824)) ([3ee10de](https://github.com/ionic-team/capacitor-plugins/commit/3ee10de98067984c1a4e75295d001c5a895c47f4))
|
|
39
|
+
* Upgrade gradle to 7.4 ([#826](https://github.com/ionic-team/capacitor-plugins/issues/826)) ([5db0906](https://github.com/ionic-team/capacitor-plugins/commit/5db0906f6264287c4f8e69dbaecf19d4d387824b))
|
|
40
|
+
* Use java 11 ([#910](https://github.com/ionic-team/capacitor-plugins/issues/910)) ([5acb2a2](https://github.com/ionic-team/capacitor-plugins/commit/5acb2a288a413492b163e4e97da46a085d9e4be0))
|
|
41
|
+
* **android:** implements Activity Result API changes for permissions and activity results ([#222](https://github.com/ionic-team/capacitor-plugins/issues/222)) ([f671b9f](https://github.com/ionic-team/capacitor-plugins/commit/f671b9f4b472806ef43db6dcf302d4503cf1828c))
|
|
42
|
+
* **filesystem:** Allow the use of absolute urls on iOS and web ([#250](https://github.com/ionic-team/capacitor-plugins/issues/250)) ([03ad97c](https://github.com/ionic-team/capacitor-plugins/commit/03ad97c1b7450e864504198853aac2b3bdc4b8a4))
|
|
43
|
+
* **filesystem:** support Library directory ([#666](https://github.com/ionic-team/capacitor-plugins/issues/666)) ([ce7ee95](https://github.com/ionic-team/capacitor-plugins/commit/ce7ee958b141f1dd4f86493923455f8264d0b6db))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
6
49
|
# [1.1.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/filesystem@1.0.7...@capacitor/filesystem@1.1.0) (2022-01-19)
|
|
7
50
|
|
|
8
51
|
|
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => 'https://github.com/ionic-team/capacitor-plugins.git', :tag => package['name'] + '@' + package['version'] }
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}', 'filesystem/ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '13.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
|
17
17
|
end
|
package/README.md
CHANGED
|
@@ -282,7 +282,7 @@ Rename a file or directory
|
|
|
282
282
|
### copy(...)
|
|
283
283
|
|
|
284
284
|
```typescript
|
|
285
|
-
copy(options: CopyOptions) => Promise<
|
|
285
|
+
copy(options: CopyOptions) => Promise<CopyResult>
|
|
286
286
|
```
|
|
287
287
|
|
|
288
288
|
Copy a file or directory
|
|
@@ -291,6 +291,8 @@ Copy a file or directory
|
|
|
291
291
|
| ------------- | --------------------------------------------------- |
|
|
292
292
|
| **`options`** | <code><a href="#copyoptions">CopyOptions</a></code> |
|
|
293
293
|
|
|
294
|
+
**Returns:** <code>Promise<<a href="#copyresult">CopyResult</a>></code>
|
|
295
|
+
|
|
294
296
|
**Since:** 1.0.0
|
|
295
297
|
|
|
296
298
|
--------------------
|
|
@@ -405,9 +407,21 @@ Required on Android, only when using <a href="#directory">`Directory.Documents`<
|
|
|
405
407
|
|
|
406
408
|
#### ReaddirResult
|
|
407
409
|
|
|
408
|
-
| Prop | Type
|
|
409
|
-
| ----------- |
|
|
410
|
-
| **`files`** | <code>
|
|
410
|
+
| Prop | Type | Description | Since |
|
|
411
|
+
| ----------- | ----------------------- | -------------------------------------------------- | ----- |
|
|
412
|
+
| **`files`** | <code>FileInfo[]</code> | List of files and directories inside the directory | 1.0.0 |
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
#### FileInfo
|
|
416
|
+
|
|
417
|
+
| Prop | Type | Description | Since |
|
|
418
|
+
| ----------- | ---------------------------------- | ------------------------------------------------------------------------------------ | ----- |
|
|
419
|
+
| **`name`** | <code>string</code> | Name of the file or directory. | |
|
|
420
|
+
| **`type`** | <code>'directory' \| 'file'</code> | Type of the file. | 4.0.0 |
|
|
421
|
+
| **`size`** | <code>number</code> | Size of the file in bytes. | 4.0.0 |
|
|
422
|
+
| **`ctime`** | <code>number</code> | Time of creation in milliseconds. It's not available on Android 7 and older devices. | 4.0.0 |
|
|
423
|
+
| **`mtime`** | <code>number</code> | Time of last modification in milliseconds. | 4.0.0 |
|
|
424
|
+
| **`uri`** | <code>string</code> | The uri of the file. | 4.0.0 |
|
|
411
425
|
|
|
412
426
|
|
|
413
427
|
#### ReaddirOptions
|
|
@@ -435,13 +449,13 @@ Required on Android, only when using <a href="#directory">`Directory.Documents`<
|
|
|
435
449
|
|
|
436
450
|
#### StatResult
|
|
437
451
|
|
|
438
|
-
| Prop | Type
|
|
439
|
-
| ----------- |
|
|
440
|
-
| **`type`** | <code>
|
|
441
|
-
| **`size`** | <code>number</code>
|
|
442
|
-
| **`ctime`** | <code>number</code>
|
|
443
|
-
| **`mtime`** | <code>number</code>
|
|
444
|
-
| **`uri`** | <code>string</code>
|
|
452
|
+
| Prop | Type | Description | Since |
|
|
453
|
+
| ----------- | ---------------------------------- | ------------------------------------------------------------------------------------ | ----- |
|
|
454
|
+
| **`type`** | <code>'directory' \| 'file'</code> | Type of the file. | 1.0.0 |
|
|
455
|
+
| **`size`** | <code>number</code> | Size of the file in bytes. | 1.0.0 |
|
|
456
|
+
| **`ctime`** | <code>number</code> | Time of creation in milliseconds. It's not available on Android 7 and older devices. | 1.0.0 |
|
|
457
|
+
| **`mtime`** | <code>number</code> | Time of last modification in milliseconds. | 1.0.0 |
|
|
458
|
+
| **`uri`** | <code>string</code> | The uri of the file | 1.0.0 |
|
|
445
459
|
|
|
446
460
|
|
|
447
461
|
#### StatOptions
|
|
@@ -462,6 +476,13 @@ Required on Android, only when using <a href="#directory">`Directory.Documents`<
|
|
|
462
476
|
| **`toDirectory`** | <code><a href="#directory">Directory</a></code> | The <a href="#directory">`Directory`</a> containing the destination file or directory. If not supplied will use the 'directory' parameter as the destination | 1.0.0 |
|
|
463
477
|
|
|
464
478
|
|
|
479
|
+
#### CopyResult
|
|
480
|
+
|
|
481
|
+
| Prop | Type | Description | Since |
|
|
482
|
+
| --------- | ------------------- | -------------------------------------- | ----- |
|
|
483
|
+
| **`uri`** | <code>string</code> | The uri where the file was copied into | 4.0.0 |
|
|
484
|
+
|
|
485
|
+
|
|
465
486
|
#### PermissionStatus
|
|
466
487
|
|
|
467
488
|
| Prop | Type |
|
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
ext {
|
|
2
|
-
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.
|
|
3
|
-
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.
|
|
4
|
-
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
|
|
4
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
buildscript {
|
|
@@ -10,17 +10,17 @@ buildscript {
|
|
|
10
10
|
mavenCentral()
|
|
11
11
|
}
|
|
12
12
|
dependencies {
|
|
13
|
-
classpath 'com.android.tools.build:gradle:
|
|
13
|
+
classpath 'com.android.tools.build:gradle:7.2.1'
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
apply plugin: 'com.android.library'
|
|
18
18
|
|
|
19
19
|
android {
|
|
20
|
-
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
20
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
|
|
21
21
|
defaultConfig {
|
|
22
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
23
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
22
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
23
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
|
|
24
24
|
versionCode 1
|
|
25
25
|
versionName "1.0"
|
|
26
26
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -35,15 +35,14 @@ android {
|
|
|
35
35
|
abortOnError false
|
|
36
36
|
}
|
|
37
37
|
compileOptions {
|
|
38
|
-
sourceCompatibility JavaVersion.
|
|
39
|
-
targetCompatibility JavaVersion.
|
|
38
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
39
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
repositories {
|
|
44
44
|
google()
|
|
45
45
|
mavenCentral()
|
|
46
|
-
jcenter()
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
|
|
@@ -72,18 +72,18 @@ public class Filesystem {
|
|
|
72
72
|
return created;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
public
|
|
76
|
-
|
|
75
|
+
public File[] readdir(String path, String directory) throws DirectoryNotFoundException {
|
|
76
|
+
File[] files = null;
|
|
77
77
|
File fileObject = getFileObject(path, directory);
|
|
78
78
|
if (fileObject != null && fileObject.exists()) {
|
|
79
|
-
files = fileObject.
|
|
79
|
+
files = fileObject.listFiles();
|
|
80
80
|
} else {
|
|
81
81
|
throw new DirectoryNotFoundException("Directory does not exist");
|
|
82
82
|
}
|
|
83
83
|
return files;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
public
|
|
86
|
+
public File copy(String from, String directory, String to, String toDirectory, boolean doRename)
|
|
87
87
|
throws IOException, CopyFailedException {
|
|
88
88
|
if (toDirectory == null) {
|
|
89
89
|
toDirectory = directory;
|
|
@@ -100,7 +100,7 @@ public class Filesystem {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
if (toObject.equals(fromObject)) {
|
|
103
|
-
return
|
|
103
|
+
return toObject;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
if (!fromObject.exists()) {
|
|
@@ -130,7 +130,7 @@ public class Filesystem {
|
|
|
130
130
|
copyRecursively(fromObject, toObject);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
return
|
|
133
|
+
return toObject;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
public InputStream getInputStream(String path, String directory) throws IOException {
|
|
@@ -180,6 +180,7 @@ public class Filesystem {
|
|
|
180
180
|
return Base64.encodeToString(byteStream.toByteArray(), Base64.NO_WRAP);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
@SuppressWarnings("deprecation")
|
|
183
184
|
public File getDirectory(String directory) {
|
|
184
185
|
Context c = this.context;
|
|
185
186
|
switch (directory) {
|
|
@@ -169,6 +169,8 @@ public class FilesystemPlugin extends Plugin {
|
|
|
169
169
|
ex
|
|
170
170
|
);
|
|
171
171
|
call.reject("FILE_NOTCREATED");
|
|
172
|
+
} catch (IllegalArgumentException ex) {
|
|
173
|
+
call.reject("The supplied data is not valid base64 content.");
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
176
|
|
|
@@ -267,10 +269,37 @@ public class FilesystemPlugin extends Plugin {
|
|
|
267
269
|
requestAllPermissions(call, "permissionCallback");
|
|
268
270
|
} else {
|
|
269
271
|
try {
|
|
270
|
-
|
|
272
|
+
File[] files = implementation.readdir(path, directory);
|
|
273
|
+
JSArray filesArray = new JSArray();
|
|
271
274
|
if (files != null) {
|
|
275
|
+
for (var i = 0; i < files.length; i++) {
|
|
276
|
+
File fileObject = files[i];
|
|
277
|
+
JSObject data = new JSObject();
|
|
278
|
+
data.put("name", fileObject.getName());
|
|
279
|
+
data.put("type", fileObject.isDirectory() ? "directory" : "file");
|
|
280
|
+
data.put("size", fileObject.length());
|
|
281
|
+
data.put("mtime", fileObject.lastModified());
|
|
282
|
+
data.put("uri", Uri.fromFile(fileObject).toString());
|
|
283
|
+
|
|
284
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
285
|
+
try {
|
|
286
|
+
BasicFileAttributes attr = Files.readAttributes(fileObject.toPath(), BasicFileAttributes.class);
|
|
287
|
+
|
|
288
|
+
// use whichever is the oldest between creationTime and lastAccessTime
|
|
289
|
+
if (attr.creationTime().toMillis() < attr.lastAccessTime().toMillis()) {
|
|
290
|
+
data.put("ctime", attr.creationTime().toMillis());
|
|
291
|
+
} else {
|
|
292
|
+
data.put("ctime", attr.lastAccessTime().toMillis());
|
|
293
|
+
}
|
|
294
|
+
} catch (Exception ex) {}
|
|
295
|
+
} else {
|
|
296
|
+
data.put("ctime", null);
|
|
297
|
+
}
|
|
298
|
+
filesArray.put(data);
|
|
299
|
+
}
|
|
300
|
+
|
|
272
301
|
JSObject ret = new JSObject();
|
|
273
|
-
ret.put("files",
|
|
302
|
+
ret.put("files", filesArray);
|
|
274
303
|
call.resolve(ret);
|
|
275
304
|
} else {
|
|
276
305
|
call.reject("Unable to read directory");
|
|
@@ -364,8 +393,14 @@ public class FilesystemPlugin extends Plugin {
|
|
|
364
393
|
}
|
|
365
394
|
}
|
|
366
395
|
try {
|
|
367
|
-
implementation.copy(from, directory, to, toDirectory, doRename);
|
|
368
|
-
|
|
396
|
+
File file = implementation.copy(from, directory, to, toDirectory, doRename);
|
|
397
|
+
if (!doRename) {
|
|
398
|
+
JSObject result = new JSObject();
|
|
399
|
+
result.put("uri", Uri.fromFile(file).toString());
|
|
400
|
+
call.resolve(result);
|
|
401
|
+
} else {
|
|
402
|
+
call.resolve();
|
|
403
|
+
}
|
|
369
404
|
} catch (CopyFailedException ex) {
|
|
370
405
|
call.reject(ex.getMessage());
|
|
371
406
|
} catch (IOException ex) {
|
package/dist/docs.json
CHANGED
|
@@ -242,7 +242,7 @@
|
|
|
242
242
|
},
|
|
243
243
|
{
|
|
244
244
|
"name": "copy",
|
|
245
|
-
"signature": "(options: CopyOptions) => Promise<
|
|
245
|
+
"signature": "(options: CopyOptions) => Promise<CopyResult>",
|
|
246
246
|
"parameters": [
|
|
247
247
|
{
|
|
248
248
|
"name": "options",
|
|
@@ -250,7 +250,7 @@
|
|
|
250
250
|
"type": "CopyOptions"
|
|
251
251
|
}
|
|
252
252
|
],
|
|
253
|
-
"returns": "Promise<
|
|
253
|
+
"returns": "Promise<CopyResult>",
|
|
254
254
|
"tags": [
|
|
255
255
|
{
|
|
256
256
|
"name": "since",
|
|
@@ -259,6 +259,7 @@
|
|
|
259
259
|
],
|
|
260
260
|
"docs": "Copy a file or directory",
|
|
261
261
|
"complexTypes": [
|
|
262
|
+
"CopyResult",
|
|
262
263
|
"CopyOptions"
|
|
263
264
|
],
|
|
264
265
|
"slug": "copy"
|
|
@@ -683,8 +684,86 @@
|
|
|
683
684
|
}
|
|
684
685
|
],
|
|
685
686
|
"docs": "List of files and directories inside the directory",
|
|
687
|
+
"complexTypes": [
|
|
688
|
+
"FileInfo"
|
|
689
|
+
],
|
|
690
|
+
"type": "FileInfo[]"
|
|
691
|
+
}
|
|
692
|
+
]
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
"name": "FileInfo",
|
|
696
|
+
"slug": "fileinfo",
|
|
697
|
+
"docs": "",
|
|
698
|
+
"tags": [],
|
|
699
|
+
"methods": [],
|
|
700
|
+
"properties": [
|
|
701
|
+
{
|
|
702
|
+
"name": "name",
|
|
703
|
+
"tags": [],
|
|
704
|
+
"docs": "Name of the file or directory.",
|
|
705
|
+
"complexTypes": [],
|
|
706
|
+
"type": "string"
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
"name": "type",
|
|
710
|
+
"tags": [
|
|
711
|
+
{
|
|
712
|
+
"text": "4.0.0",
|
|
713
|
+
"name": "since"
|
|
714
|
+
}
|
|
715
|
+
],
|
|
716
|
+
"docs": "Type of the file.",
|
|
717
|
+
"complexTypes": [],
|
|
718
|
+
"type": "'directory' | 'file'"
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
"name": "size",
|
|
722
|
+
"tags": [
|
|
723
|
+
{
|
|
724
|
+
"text": "4.0.0",
|
|
725
|
+
"name": "since"
|
|
726
|
+
}
|
|
727
|
+
],
|
|
728
|
+
"docs": "Size of the file in bytes.",
|
|
686
729
|
"complexTypes": [],
|
|
687
|
-
"type": "
|
|
730
|
+
"type": "number"
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
"name": "ctime",
|
|
734
|
+
"tags": [
|
|
735
|
+
{
|
|
736
|
+
"text": "4.0.0",
|
|
737
|
+
"name": "since"
|
|
738
|
+
}
|
|
739
|
+
],
|
|
740
|
+
"docs": "Time of creation in milliseconds.\n\nIt's not available on Android 7 and older devices.",
|
|
741
|
+
"complexTypes": [],
|
|
742
|
+
"type": "number | undefined"
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
"name": "mtime",
|
|
746
|
+
"tags": [
|
|
747
|
+
{
|
|
748
|
+
"text": "4.0.0",
|
|
749
|
+
"name": "since"
|
|
750
|
+
}
|
|
751
|
+
],
|
|
752
|
+
"docs": "Time of last modification in milliseconds.",
|
|
753
|
+
"complexTypes": [],
|
|
754
|
+
"type": "number"
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
"name": "uri",
|
|
758
|
+
"tags": [
|
|
759
|
+
{
|
|
760
|
+
"text": "4.0.0",
|
|
761
|
+
"name": "since"
|
|
762
|
+
}
|
|
763
|
+
],
|
|
764
|
+
"docs": "The uri of the file.",
|
|
765
|
+
"complexTypes": [],
|
|
766
|
+
"type": "string"
|
|
688
767
|
}
|
|
689
768
|
]
|
|
690
769
|
},
|
|
@@ -794,9 +873,9 @@
|
|
|
794
873
|
"name": "since"
|
|
795
874
|
}
|
|
796
875
|
],
|
|
797
|
-
"docs": "Type of the file",
|
|
876
|
+
"docs": "Type of the file.",
|
|
798
877
|
"complexTypes": [],
|
|
799
|
-
"type": "
|
|
878
|
+
"type": "'directory' | 'file'"
|
|
800
879
|
},
|
|
801
880
|
{
|
|
802
881
|
"name": "size",
|
|
@@ -806,7 +885,7 @@
|
|
|
806
885
|
"name": "since"
|
|
807
886
|
}
|
|
808
887
|
],
|
|
809
|
-
"docs": "Size of the file",
|
|
888
|
+
"docs": "Size of the file in bytes.",
|
|
810
889
|
"complexTypes": [],
|
|
811
890
|
"type": "number"
|
|
812
891
|
},
|
|
@@ -944,6 +1023,27 @@
|
|
|
944
1023
|
}
|
|
945
1024
|
]
|
|
946
1025
|
},
|
|
1026
|
+
{
|
|
1027
|
+
"name": "CopyResult",
|
|
1028
|
+
"slug": "copyresult",
|
|
1029
|
+
"docs": "",
|
|
1030
|
+
"tags": [],
|
|
1031
|
+
"methods": [],
|
|
1032
|
+
"properties": [
|
|
1033
|
+
{
|
|
1034
|
+
"name": "uri",
|
|
1035
|
+
"tags": [
|
|
1036
|
+
{
|
|
1037
|
+
"text": "4.0.0",
|
|
1038
|
+
"name": "since"
|
|
1039
|
+
}
|
|
1040
|
+
],
|
|
1041
|
+
"docs": "The uri where the file was copied into",
|
|
1042
|
+
"complexTypes": [],
|
|
1043
|
+
"type": "string"
|
|
1044
|
+
}
|
|
1045
|
+
]
|
|
1046
|
+
},
|
|
947
1047
|
{
|
|
948
1048
|
"name": "PermissionStatus",
|
|
949
1049
|
"slug": "permissionstatus",
|
|
@@ -327,7 +327,45 @@ export interface ReaddirResult {
|
|
|
327
327
|
*
|
|
328
328
|
* @since 1.0.0
|
|
329
329
|
*/
|
|
330
|
-
files:
|
|
330
|
+
files: FileInfo[];
|
|
331
|
+
}
|
|
332
|
+
export interface FileInfo {
|
|
333
|
+
/**
|
|
334
|
+
* Name of the file or directory.
|
|
335
|
+
*/
|
|
336
|
+
name: string;
|
|
337
|
+
/**
|
|
338
|
+
* Type of the file.
|
|
339
|
+
*
|
|
340
|
+
* @since 4.0.0
|
|
341
|
+
*/
|
|
342
|
+
type: 'directory' | 'file';
|
|
343
|
+
/**
|
|
344
|
+
* Size of the file in bytes.
|
|
345
|
+
*
|
|
346
|
+
* @since 4.0.0
|
|
347
|
+
*/
|
|
348
|
+
size: number;
|
|
349
|
+
/**
|
|
350
|
+
* Time of creation in milliseconds.
|
|
351
|
+
*
|
|
352
|
+
* It's not available on Android 7 and older devices.
|
|
353
|
+
*
|
|
354
|
+
* @since 4.0.0
|
|
355
|
+
*/
|
|
356
|
+
ctime?: number;
|
|
357
|
+
/**
|
|
358
|
+
* Time of last modification in milliseconds.
|
|
359
|
+
*
|
|
360
|
+
* @since 4.0.0
|
|
361
|
+
*/
|
|
362
|
+
mtime: number;
|
|
363
|
+
/**
|
|
364
|
+
* The uri of the file.
|
|
365
|
+
*
|
|
366
|
+
* @since 4.0.0
|
|
367
|
+
*/
|
|
368
|
+
uri: string;
|
|
331
369
|
}
|
|
332
370
|
export interface GetUriResult {
|
|
333
371
|
/**
|
|
@@ -339,13 +377,13 @@ export interface GetUriResult {
|
|
|
339
377
|
}
|
|
340
378
|
export interface StatResult {
|
|
341
379
|
/**
|
|
342
|
-
* Type of the file
|
|
380
|
+
* Type of the file.
|
|
343
381
|
*
|
|
344
382
|
* @since 1.0.0
|
|
345
383
|
*/
|
|
346
|
-
type:
|
|
384
|
+
type: 'directory' | 'file';
|
|
347
385
|
/**
|
|
348
|
-
* Size of the file
|
|
386
|
+
* Size of the file in bytes.
|
|
349
387
|
*
|
|
350
388
|
* @since 1.0.0
|
|
351
389
|
*/
|
|
@@ -371,6 +409,14 @@ export interface StatResult {
|
|
|
371
409
|
*/
|
|
372
410
|
uri: string;
|
|
373
411
|
}
|
|
412
|
+
export interface CopyResult {
|
|
413
|
+
/**
|
|
414
|
+
* The uri where the file was copied into
|
|
415
|
+
*
|
|
416
|
+
* @since 4.0.0
|
|
417
|
+
*/
|
|
418
|
+
uri: string;
|
|
419
|
+
}
|
|
374
420
|
export interface FilesystemPlugin {
|
|
375
421
|
/**
|
|
376
422
|
* Read a file from disk
|
|
@@ -437,7 +483,7 @@ export interface FilesystemPlugin {
|
|
|
437
483
|
*
|
|
438
484
|
* @since 1.0.0
|
|
439
485
|
*/
|
|
440
|
-
copy(options: CopyOptions): Promise<
|
|
486
|
+
copy(options: CopyOptions): Promise<CopyResult>;
|
|
441
487
|
/**
|
|
442
488
|
* Check read/write permissions.
|
|
443
489
|
* Required on Android, only when using `Directory.Documents` or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,SAqEX;AArED,WAAY,SAAS;IACnB;;;;;;;;;;;OAWG;IACH,oCAAuB,CAAA;IAEvB;;;;;;;OAOG;IACH,0BAAa,CAAA;IAEb;;;;;;;OAOG;IACH,gCAAmB,CAAA;IAEnB;;;;;;OAMG;IACH,4BAAe,CAAA;IAEf;;;;;;;;;;OAUG;IACH,kCAAqB,CAAA;IAErB;;;;;;;;;;OAUG;IACH,iDAAoC,CAAA;AACtC,CAAC,EArEW,SAAS,KAAT,SAAS,QAqEpB;AAED,MAAM,CAAN,IAAY,QAyBX;AAzBD,WAAY,QAAQ;IAClB;;;;OAIG;IACH,yBAAa,CAAA;IAEb;;;;;;OAMG;IACH,2BAAe,CAAA;IAEf;;;;;;OAMG;IACH,2BAAe,CAAA;AACjB,CAAC,EAzBW,QAAQ,KAAR,QAAQ,QAyBnB;AAucD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import type { PermissionState } from '@capacitor/core';\n\nexport interface PermissionStatus {\n publicStorage: PermissionState;\n}\n\nexport enum Directory {\n /**\n * The Documents directory\n * On iOS it's the app's documents directory.\n * Use this directory to store user-generated content.\n * On Android it's the Public Documents folder, so it's accessible from other apps.\n * It's not accesible on Android 10 unless the app enables legacy External Storage\n * by adding `android:requestLegacyExternalStorage=\"true\"` in the `application` tag\n * in the `AndroidManifest.xml`.\n * It's not accesible on Android 11 or newer.\n *\n * @since 1.0.0\n */\n Documents = 'DOCUMENTS',\n\n /**\n * The Data directory\n * On iOS it will use the Documents directory.\n * On Android it's the directory holding application files.\n * Files will be deleted when the application is uninstalled.\n *\n * @since 1.0.0\n */\n Data = 'DATA',\n\n /**\n * The Library directory\n * On iOS it will use the Library directory.\n * On Android it's the directory holding application files.\n * Files will be deleted when the application is uninstalled.\n *\n * @since 1.1.0\n */\n Library = 'LIBRARY',\n\n /**\n * The Cache directory\n * Can be deleted in cases of low memory, so use this directory to write app-specific files\n * that your app can re-create easily.\n *\n * @since 1.0.0\n */\n Cache = 'CACHE',\n\n /**\n * The external directory\n * On iOS it will use the Documents directory\n * On Android it's the directory on the primary shared/external\n * storage device where the application can place persistent files it owns.\n * These files are internal to the applications, and not typically visible\n * to the user as media.\n * Files will be deleted when the application is uninstalled.\n *\n * @since 1.0.0\n */\n External = 'EXTERNAL',\n\n /**\n * The external storage directory\n * On iOS it will use the Documents directory\n * On Android it's the primary shared/external storage directory.\n * It's not accesible on Android 10 unless the app enables legacy External Storage\n * by adding `android:requestLegacyExternalStorage=\"true\"` in the `application` tag\n * in the `AndroidManifest.xml`.\n * It's not accesible on Android 11 or newer.\n *\n * @since 1.0.0\n */\n ExternalStorage = 'EXTERNAL_STORAGE',\n}\n\nexport enum Encoding {\n /**\n * Eight-bit UCS Transformation Format\n *\n * @since 1.0.0\n */\n UTF8 = 'utf8',\n\n /**\n * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the\n * Unicode character set\n * This encoding is only supported on Android.\n *\n * @since 1.0.0\n */\n ASCII = 'ascii',\n\n /**\n * Sixteen-bit UCS Transformation Format, byte order identified by an\n * optional byte-order mark\n * This encoding is only supported on Android.\n *\n * @since 1.0.0\n */\n UTF16 = 'utf16',\n}\n\nexport interface WriteFileOptions {\n /**\n * The path of the file to write\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The data to write\n *\n * @since 1.0.0\n */\n data: string;\n\n /**\n * The `Directory` to store the file in\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The encoding to write the file in. If not provided, data\n * is written as base64 encoded.\n *\n * Pass Encoding.UTF8 to write data as string\n *\n * @since 1.0.0\n */\n encoding?: Encoding;\n\n /**\n * Whether to create any missing parent directories.\n *\n * @default false\n * @since 1.0.0\n */\n recursive?: boolean;\n}\n\nexport interface AppendFileOptions {\n /**\n * The path of the file to append\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The data to write\n *\n * @since 1.0.0\n */\n data: string;\n\n /**\n * The `Directory` to store the file in\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The encoding to write the file in. If not provided, data\n * is written as base64 encoded.\n *\n * Pass Encoding.UTF8 to write data as string\n *\n * @since 1.0.0\n */\n encoding?: Encoding;\n}\n\nexport interface ReadFileOptions {\n /**\n * The path of the file to read\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to read the file from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The encoding to read the file in, if not provided, data\n * is read as binary and returned as base64 encoded.\n *\n * Pass Encoding.UTF8 to read data as string\n *\n * @since 1.0.0\n */\n encoding?: Encoding;\n}\n\nexport interface DeleteFileOptions {\n /**\n * The path of the file to delete\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to delete the file from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n}\n\nexport interface MkdirOptions {\n /**\n * The path of the new directory\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to make the new directory in\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * Whether to create any missing parent directories as well.\n *\n * @default false\n * @since 1.0.0\n */\n recursive?: boolean;\n}\n\nexport interface RmdirOptions {\n /**\n * The path of the directory to remove\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to remove the directory from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * Whether to recursively remove the contents of the directory\n *\n * @default false\n * @since 1.0.0\n */\n recursive?: boolean;\n}\n\nexport interface ReaddirOptions {\n /**\n * The path of the directory to read\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to list files from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n}\n\nexport interface GetUriOptions {\n /**\n * The path of the file to get the URI for\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to get the file under\n *\n * @since 1.0.0\n */\n directory: Directory;\n}\n\nexport interface StatOptions {\n /**\n * The path of the file to get data about\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to get the file under\n *\n * @since 1.0.0\n */\n directory?: Directory;\n}\n\nexport interface CopyOptions {\n /**\n * The existing file or directory\n *\n * @since 1.0.0\n */\n from: string;\n\n /**\n * The destination file or directory\n *\n * @since 1.0.0\n */\n to: string;\n\n /**\n * The `Directory` containing the existing file or directory\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The `Directory` containing the destination file or directory. If not supplied will use the 'directory'\n * parameter as the destination\n *\n * @since 1.0.0\n */\n toDirectory?: Directory;\n}\n\nexport type RenameOptions = CopyOptions;\n\nexport interface ReadFileResult {\n /**\n * The string representation of the data contained in the file\n *\n * @since 1.0.0\n */\n data: string;\n}\n\nexport interface WriteFileResult {\n /**\n * The uri where the file was written into\n *\n * @since 1.0.0\n */\n uri: string;\n}\n\nexport interface ReaddirResult {\n /**\n * List of files and directories inside the directory\n *\n * @since 1.0.0\n */\n files: string[];\n}\n\nexport interface GetUriResult {\n /**\n * The uri of the file\n *\n * @since 1.0.0\n */\n uri: string;\n}\n\nexport interface StatResult {\n /**\n * Type of the file\n *\n * @since 1.0.0\n */\n type: string;\n\n /**\n * Size of the file\n *\n * @since 1.0.0\n */\n size: number;\n\n /**\n * Time of creation in milliseconds.\n *\n * It's not available on Android 7 and older devices.\n *\n * @since 1.0.0\n */\n ctime?: number;\n\n /**\n * Time of last modification in milliseconds.\n *\n * @since 1.0.0\n */\n mtime: number;\n\n /**\n * The uri of the file\n *\n * @since 1.0.0\n */\n uri: string;\n}\n\nexport interface FilesystemPlugin {\n /**\n * Read a file from disk\n *\n * @since 1.0.0\n */\n readFile(options: ReadFileOptions): Promise<ReadFileResult>;\n\n /**\n * Write a file to disk in the specified location on device\n *\n * @since 1.0.0\n */\n writeFile(options: WriteFileOptions): Promise<WriteFileResult>;\n\n /**\n * Append to a file on disk in the specified location on device\n *\n * @since 1.0.0\n */\n appendFile(options: AppendFileOptions): Promise<void>;\n\n /**\n * Delete a file from disk\n *\n * @since 1.0.0\n */\n deleteFile(options: DeleteFileOptions): Promise<void>;\n\n /**\n * Create a directory.\n *\n * @since 1.0.0\n */\n mkdir(options: MkdirOptions): Promise<void>;\n\n /**\n * Remove a directory\n *\n * @since 1.0.0\n */\n rmdir(options: RmdirOptions): Promise<void>;\n\n /**\n * Return a list of files from the directory (not recursive)\n *\n * @since 1.0.0\n */\n readdir(options: ReaddirOptions): Promise<ReaddirResult>;\n\n /**\n * Return full File URI for a path and directory\n *\n * @since 1.0.0\n */\n getUri(options: GetUriOptions): Promise<GetUriResult>;\n\n /**\n * Return data about a file\n *\n * @since 1.0.0\n */\n stat(options: StatOptions): Promise<StatResult>;\n\n /**\n * Rename a file or directory\n *\n * @since 1.0.0\n */\n rename(options: RenameOptions): Promise<void>;\n\n /**\n * Copy a file or directory\n *\n * @since 1.0.0\n */\n copy(options: CopyOptions): Promise<void>;\n\n /**\n * Check read/write permissions.\n * Required on Android, only when using `Directory.Documents` or\n * `Directory.ExternalStorage`.\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request read/write permissions.\n * Required on Android, only when using `Directory.Documents` or\n * `Directory.ExternalStorage`.\n *\n * @since 1.0.0\n */\n requestPermissions(): Promise<PermissionStatus>;\n}\n\n/**\n * @deprecated Use `ReadFileOptions`.\n * @since 1.0.0\n */\nexport type FileReadOptions = ReadFileOptions;\n\n/**\n * @deprecated Use `ReadFileResult`.\n * @since 1.0.0\n */\nexport type FileReadResult = ReadFileResult;\n\n/**\n * @deprecated Use `WriteFileOptions`.\n * @since 1.0.0\n */\nexport type FileWriteOptions = WriteFileOptions;\n\n/**\n * @deprecated Use `WriteFileResult`.\n * @since 1.0.0\n */\nexport type FileWriteResult = WriteFileResult;\n\n/**\n * @deprecated Use `AppendFileOptions`.\n * @since 1.0.0\n */\nexport type FileAppendOptions = AppendFileOptions;\n\n/**\n * @deprecated Use `DeleteFileOptions`.\n * @since 1.0.0\n */\nexport type FileDeleteOptions = DeleteFileOptions;\n\n/**\n * @deprecated Use `Directory`.\n * @since 1.0.0\n */\nexport const FilesystemDirectory = Directory;\n\n/**\n * @deprecated Use `Encoding`.\n * @since 1.0.0\n */\nexport const FilesystemEncoding = Encoding;\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,SAqEX;AArED,WAAY,SAAS;IACnB;;;;;;;;;;;OAWG;IACH,oCAAuB,CAAA;IAEvB;;;;;;;OAOG;IACH,0BAAa,CAAA;IAEb;;;;;;;OAOG;IACH,gCAAmB,CAAA;IAEnB;;;;;;OAMG;IACH,4BAAe,CAAA;IAEf;;;;;;;;;;OAUG;IACH,kCAAqB,CAAA;IAErB;;;;;;;;;;OAUG;IACH,iDAAoC,CAAA;AACtC,CAAC,EArEW,SAAS,KAAT,SAAS,QAqEpB;AAED,MAAM,CAAN,IAAY,QAyBX;AAzBD,WAAY,QAAQ;IAClB;;;;OAIG;IACH,yBAAa,CAAA;IAEb;;;;;;OAMG;IACH,2BAAe,CAAA;IAEf;;;;;;OAMG;IACH,2BAAe,CAAA;AACjB,CAAC,EAzBW,QAAQ,KAAR,QAAQ,QAyBnB;AA2fD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import type { PermissionState } from '@capacitor/core';\n\nexport interface PermissionStatus {\n publicStorage: PermissionState;\n}\n\nexport enum Directory {\n /**\n * The Documents directory\n * On iOS it's the app's documents directory.\n * Use this directory to store user-generated content.\n * On Android it's the Public Documents folder, so it's accessible from other apps.\n * It's not accesible on Android 10 unless the app enables legacy External Storage\n * by adding `android:requestLegacyExternalStorage=\"true\"` in the `application` tag\n * in the `AndroidManifest.xml`.\n * It's not accesible on Android 11 or newer.\n *\n * @since 1.0.0\n */\n Documents = 'DOCUMENTS',\n\n /**\n * The Data directory\n * On iOS it will use the Documents directory.\n * On Android it's the directory holding application files.\n * Files will be deleted when the application is uninstalled.\n *\n * @since 1.0.0\n */\n Data = 'DATA',\n\n /**\n * The Library directory\n * On iOS it will use the Library directory.\n * On Android it's the directory holding application files.\n * Files will be deleted when the application is uninstalled.\n *\n * @since 1.1.0\n */\n Library = 'LIBRARY',\n\n /**\n * The Cache directory\n * Can be deleted in cases of low memory, so use this directory to write app-specific files\n * that your app can re-create easily.\n *\n * @since 1.0.0\n */\n Cache = 'CACHE',\n\n /**\n * The external directory\n * On iOS it will use the Documents directory\n * On Android it's the directory on the primary shared/external\n * storage device where the application can place persistent files it owns.\n * These files are internal to the applications, and not typically visible\n * to the user as media.\n * Files will be deleted when the application is uninstalled.\n *\n * @since 1.0.0\n */\n External = 'EXTERNAL',\n\n /**\n * The external storage directory\n * On iOS it will use the Documents directory\n * On Android it's the primary shared/external storage directory.\n * It's not accesible on Android 10 unless the app enables legacy External Storage\n * by adding `android:requestLegacyExternalStorage=\"true\"` in the `application` tag\n * in the `AndroidManifest.xml`.\n * It's not accesible on Android 11 or newer.\n *\n * @since 1.0.0\n */\n ExternalStorage = 'EXTERNAL_STORAGE',\n}\n\nexport enum Encoding {\n /**\n * Eight-bit UCS Transformation Format\n *\n * @since 1.0.0\n */\n UTF8 = 'utf8',\n\n /**\n * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the\n * Unicode character set\n * This encoding is only supported on Android.\n *\n * @since 1.0.0\n */\n ASCII = 'ascii',\n\n /**\n * Sixteen-bit UCS Transformation Format, byte order identified by an\n * optional byte-order mark\n * This encoding is only supported on Android.\n *\n * @since 1.0.0\n */\n UTF16 = 'utf16',\n}\n\nexport interface WriteFileOptions {\n /**\n * The path of the file to write\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The data to write\n *\n * @since 1.0.0\n */\n data: string;\n\n /**\n * The `Directory` to store the file in\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The encoding to write the file in. If not provided, data\n * is written as base64 encoded.\n *\n * Pass Encoding.UTF8 to write data as string\n *\n * @since 1.0.0\n */\n encoding?: Encoding;\n\n /**\n * Whether to create any missing parent directories.\n *\n * @default false\n * @since 1.0.0\n */\n recursive?: boolean;\n}\n\nexport interface AppendFileOptions {\n /**\n * The path of the file to append\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The data to write\n *\n * @since 1.0.0\n */\n data: string;\n\n /**\n * The `Directory` to store the file in\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The encoding to write the file in. If not provided, data\n * is written as base64 encoded.\n *\n * Pass Encoding.UTF8 to write data as string\n *\n * @since 1.0.0\n */\n encoding?: Encoding;\n}\n\nexport interface ReadFileOptions {\n /**\n * The path of the file to read\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to read the file from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The encoding to read the file in, if not provided, data\n * is read as binary and returned as base64 encoded.\n *\n * Pass Encoding.UTF8 to read data as string\n *\n * @since 1.0.0\n */\n encoding?: Encoding;\n}\n\nexport interface DeleteFileOptions {\n /**\n * The path of the file to delete\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to delete the file from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n}\n\nexport interface MkdirOptions {\n /**\n * The path of the new directory\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to make the new directory in\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * Whether to create any missing parent directories as well.\n *\n * @default false\n * @since 1.0.0\n */\n recursive?: boolean;\n}\n\nexport interface RmdirOptions {\n /**\n * The path of the directory to remove\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to remove the directory from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * Whether to recursively remove the contents of the directory\n *\n * @default false\n * @since 1.0.0\n */\n recursive?: boolean;\n}\n\nexport interface ReaddirOptions {\n /**\n * The path of the directory to read\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to list files from\n *\n * @since 1.0.0\n */\n directory?: Directory;\n}\n\nexport interface GetUriOptions {\n /**\n * The path of the file to get the URI for\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to get the file under\n *\n * @since 1.0.0\n */\n directory: Directory;\n}\n\nexport interface StatOptions {\n /**\n * The path of the file to get data about\n *\n * @since 1.0.0\n */\n path: string;\n\n /**\n * The `Directory` to get the file under\n *\n * @since 1.0.0\n */\n directory?: Directory;\n}\n\nexport interface CopyOptions {\n /**\n * The existing file or directory\n *\n * @since 1.0.0\n */\n from: string;\n\n /**\n * The destination file or directory\n *\n * @since 1.0.0\n */\n to: string;\n\n /**\n * The `Directory` containing the existing file or directory\n *\n * @since 1.0.0\n */\n directory?: Directory;\n\n /**\n * The `Directory` containing the destination file or directory. If not supplied will use the 'directory'\n * parameter as the destination\n *\n * @since 1.0.0\n */\n toDirectory?: Directory;\n}\n\nexport type RenameOptions = CopyOptions;\n\nexport interface ReadFileResult {\n /**\n * The string representation of the data contained in the file\n *\n * @since 1.0.0\n */\n data: string;\n}\n\nexport interface WriteFileResult {\n /**\n * The uri where the file was written into\n *\n * @since 1.0.0\n */\n uri: string;\n}\n\nexport interface ReaddirResult {\n /**\n * List of files and directories inside the directory\n *\n * @since 1.0.0\n */\n files: FileInfo[];\n}\n\nexport interface FileInfo {\n /**\n * Name of the file or directory.\n */\n name: string;\n /**\n * Type of the file.\n *\n * @since 4.0.0\n */\n type: 'directory' | 'file';\n\n /**\n * Size of the file in bytes.\n *\n * @since 4.0.0\n */\n size: number;\n\n /**\n * Time of creation in milliseconds.\n *\n * It's not available on Android 7 and older devices.\n *\n * @since 4.0.0\n */\n ctime?: number;\n\n /**\n * Time of last modification in milliseconds.\n *\n * @since 4.0.0\n */\n mtime: number;\n\n /**\n * The uri of the file.\n *\n * @since 4.0.0\n */\n uri: string;\n}\n\nexport interface GetUriResult {\n /**\n * The uri of the file\n *\n * @since 1.0.0\n */\n uri: string;\n}\n\nexport interface StatResult {\n /**\n * Type of the file.\n *\n * @since 1.0.0\n */\n type: 'directory' | 'file';\n\n /**\n * Size of the file in bytes.\n *\n * @since 1.0.0\n */\n size: number;\n\n /**\n * Time of creation in milliseconds.\n *\n * It's not available on Android 7 and older devices.\n *\n * @since 1.0.0\n */\n ctime?: number;\n\n /**\n * Time of last modification in milliseconds.\n *\n * @since 1.0.0\n */\n mtime: number;\n\n /**\n * The uri of the file\n *\n * @since 1.0.0\n */\n uri: string;\n}\n\nexport interface CopyResult {\n /**\n * The uri where the file was copied into\n *\n * @since 4.0.0\n */\n uri: string;\n}\n\nexport interface FilesystemPlugin {\n /**\n * Read a file from disk\n *\n * @since 1.0.0\n */\n readFile(options: ReadFileOptions): Promise<ReadFileResult>;\n\n /**\n * Write a file to disk in the specified location on device\n *\n * @since 1.0.0\n */\n writeFile(options: WriteFileOptions): Promise<WriteFileResult>;\n\n /**\n * Append to a file on disk in the specified location on device\n *\n * @since 1.0.0\n */\n appendFile(options: AppendFileOptions): Promise<void>;\n\n /**\n * Delete a file from disk\n *\n * @since 1.0.0\n */\n deleteFile(options: DeleteFileOptions): Promise<void>;\n\n /**\n * Create a directory.\n *\n * @since 1.0.0\n */\n mkdir(options: MkdirOptions): Promise<void>;\n\n /**\n * Remove a directory\n *\n * @since 1.0.0\n */\n rmdir(options: RmdirOptions): Promise<void>;\n\n /**\n * Return a list of files from the directory (not recursive)\n *\n * @since 1.0.0\n */\n readdir(options: ReaddirOptions): Promise<ReaddirResult>;\n\n /**\n * Return full File URI for a path and directory\n *\n * @since 1.0.0\n */\n getUri(options: GetUriOptions): Promise<GetUriResult>;\n\n /**\n * Return data about a file\n *\n * @since 1.0.0\n */\n stat(options: StatOptions): Promise<StatResult>;\n\n /**\n * Rename a file or directory\n *\n * @since 1.0.0\n */\n rename(options: RenameOptions): Promise<void>;\n\n /**\n * Copy a file or directory\n *\n * @since 1.0.0\n */\n copy(options: CopyOptions): Promise<CopyResult>;\n\n /**\n * Check read/write permissions.\n * Required on Android, only when using `Directory.Documents` or\n * `Directory.ExternalStorage`.\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request read/write permissions.\n * Required on Android, only when using `Directory.Documents` or\n * `Directory.ExternalStorage`.\n *\n * @since 1.0.0\n */\n requestPermissions(): Promise<PermissionStatus>;\n}\n\n/**\n * @deprecated Use `ReadFileOptions`.\n * @since 1.0.0\n */\nexport type FileReadOptions = ReadFileOptions;\n\n/**\n * @deprecated Use `ReadFileResult`.\n * @since 1.0.0\n */\nexport type FileReadResult = ReadFileResult;\n\n/**\n * @deprecated Use `WriteFileOptions`.\n * @since 1.0.0\n */\nexport type FileWriteOptions = WriteFileOptions;\n\n/**\n * @deprecated Use `WriteFileResult`.\n * @since 1.0.0\n */\nexport type FileWriteResult = WriteFileResult;\n\n/**\n * @deprecated Use `AppendFileOptions`.\n * @since 1.0.0\n */\nexport type FileAppendOptions = AppendFileOptions;\n\n/**\n * @deprecated Use `DeleteFileOptions`.\n * @since 1.0.0\n */\nexport type FileDeleteOptions = DeleteFileOptions;\n\n/**\n * @deprecated Use `Directory`.\n * @since 1.0.0\n */\nexport const FilesystemDirectory = Directory;\n\n/**\n * @deprecated Use `Encoding`.\n * @since 1.0.0\n */\nexport const FilesystemEncoding = Encoding;\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { AppendFileOptions, CopyOptions, DeleteFileOptions, FilesystemPlugin, GetUriOptions, GetUriResult, MkdirOptions, PermissionStatus, ReadFileOptions, ReadFileResult, ReaddirOptions, ReaddirResult, RenameOptions, RmdirOptions, StatOptions, StatResult, WriteFileOptions, WriteFileResult } from './definitions';
|
|
2
|
+
import type { AppendFileOptions, CopyOptions, CopyResult, DeleteFileOptions, FilesystemPlugin, GetUriOptions, GetUriResult, MkdirOptions, PermissionStatus, ReadFileOptions, ReadFileResult, ReaddirOptions, ReaddirResult, RenameOptions, RmdirOptions, StatOptions, StatResult, WriteFileOptions, WriteFileResult } from './definitions';
|
|
3
3
|
export declare class FilesystemWeb extends WebPlugin implements FilesystemPlugin {
|
|
4
4
|
DB_VERSION: number;
|
|
5
5
|
DB_NAME: string;
|
|
@@ -76,7 +76,7 @@ export declare class FilesystemWeb extends WebPlugin implements FilesystemPlugin
|
|
|
76
76
|
* @param options the options for the copy operation
|
|
77
77
|
* @return a promise that resolves with the copy result
|
|
78
78
|
*/
|
|
79
|
-
copy(options: CopyOptions): Promise<
|
|
79
|
+
copy(options: CopyOptions): Promise<CopyResult>;
|
|
80
80
|
requestPermissions(): Promise<PermissionStatus>;
|
|
81
81
|
checkPermissions(): Promise<PermissionStatus>;
|
|
82
82
|
/**
|
|
@@ -86,4 +86,5 @@ export declare class FilesystemWeb extends WebPlugin implements FilesystemPlugin
|
|
|
86
86
|
* @return a promise that resolves with the result
|
|
87
87
|
*/
|
|
88
88
|
private _copy;
|
|
89
|
+
private isBase64String;
|
|
89
90
|
}
|