expo-file-system 19.1.0-canary-20250830-81bb199 → 19.1.0-canary-20250919-7a31b96
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 +53 -1
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/filesystem/FileSystemDirectory.kt +7 -0
- package/android/src/main/java/expo/modules/filesystem/FileSystemModule.kt +12 -6
- package/android/src/main/java/expo/modules/filesystem/FileSystemNextRecords.kt +6 -2
- package/android/src/main/java/expo/modules/filesystem/legacy/FileSystemLegacyModule.kt +11 -5
- package/build/ExpoFileSystem.types.d.ts +45 -12
- package/build/ExpoFileSystem.types.d.ts.map +1 -1
- package/build/ExpoFileSystem.web.d.ts +20 -0
- package/build/ExpoFileSystem.web.d.ts.map +1 -0
- package/build/index.d.ts +2 -1
- package/build/index.d.ts.map +1 -1
- package/build/legacyWarnings.d.ts +66 -0
- package/build/legacyWarnings.d.ts.map +1 -0
- package/expo-module.config.json +1 -1
- package/ios/FilePickingHandler.swift +95 -0
- package/ios/FilePickingUtils.swift +167 -0
- package/ios/FileSystemDirectory.swift +46 -34
- package/ios/FileSystemExceptions.swift +30 -0
- package/ios/FileSystemFile.swift +52 -50
- package/ios/FileSystemModule.swift +51 -8
- package/ios/FileSystemPath.swift +17 -0
- package/ios/FileSystemRecords.swift +2 -0
- package/ios/Legacy/FileSystemLegacyModule.swift +10 -6
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.module → 19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.module} +22 -22
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.pom → 19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250919-7a31b96/expo.modules.filesystem-19.1.0-canary-20250919-7a31b96.pom.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml +4 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha512 +1 -1
- package/next.ts +1 -0
- package/package.json +4 -4
- package/src/ExpoFileSystem.types.ts +46 -12
- package/src/ExpoFileSystem.web.ts +48 -0
- package/src/index.ts +4 -1
- package/src/legacyWarnings.ts +163 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.1.0-canary-20250830-81bb199/expo.modules.filesystem-19.1.0-canary-20250830-81bb199.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,12 +6,63 @@
|
|
|
6
6
|
|
|
7
7
|
### 🎉 New features
|
|
8
8
|
|
|
9
|
-
-
|
|
9
|
+
- add `idempotent` option to `downloadFileAsync` ([#39681](https://github.com/expo/expo/pull/39681) by [@vonovak](https://github.com/vonovak))
|
|
10
10
|
|
|
11
11
|
### 🐛 Bug fixes
|
|
12
12
|
|
|
13
13
|
### 💡 Others
|
|
14
14
|
|
|
15
|
+
## 19.0.14 — 2025-09-13
|
|
16
|
+
|
|
17
|
+
_This version does not introduce any user-facing changes._
|
|
18
|
+
|
|
19
|
+
## 19.0.13 — 2025-09-12
|
|
20
|
+
|
|
21
|
+
### 🐛 Bug fixes
|
|
22
|
+
|
|
23
|
+
- [Android] Fix incorrect AndroidManifest.xml location. ([#39134](https://github.com/expo/expo/pull/39134) by [@robertying](https://github.com/robertying))
|
|
24
|
+
|
|
25
|
+
## 19.0.12 — 2025-09-11
|
|
26
|
+
|
|
27
|
+
_This version does not introduce any user-facing changes._
|
|
28
|
+
|
|
29
|
+
## 19.0.11 — 2025-09-10
|
|
30
|
+
|
|
31
|
+
### 🎉 New features
|
|
32
|
+
|
|
33
|
+
- [iOS] Add `pickDirectoryAsync` support ([#39210](https://github.com/expo/expo/pull/39210) by [@kosmydel](https://github.com/kosmydel))
|
|
34
|
+
|
|
35
|
+
### 🐛 Bug fixes
|
|
36
|
+
|
|
37
|
+
- Add minimal web stub to fix broken imports on web ([#39400](https://github.com/expo/expo/pull/39400) by [@LeonDvlpmnt](https://github.com/LeonDvlpmnt))
|
|
38
|
+
|
|
39
|
+
## 19.0.10 — 2025-09-08
|
|
40
|
+
|
|
41
|
+
_This version does not introduce any user-facing changes._
|
|
42
|
+
|
|
43
|
+
## 19.0.9 — 2025-09-03
|
|
44
|
+
|
|
45
|
+
### 🎉 New features
|
|
46
|
+
|
|
47
|
+
- Add stubs for legacy methods imported from "expo-file-system". ([#39244](https://github.com/expo/expo/pull/39244) by [@aleqsio](https://github.com/aleqsio))
|
|
48
|
+
|
|
49
|
+
### 🐛 Bug fixes
|
|
50
|
+
|
|
51
|
+
- [iOS] Fix tvOS compile error. ([#39345](https://github.com/expo/expo/pull/39345) by [@douglowder](https://github.com/douglowder))
|
|
52
|
+
|
|
53
|
+
## 19.0.8 — 2025-09-02
|
|
54
|
+
|
|
55
|
+
### 🎉 New features
|
|
56
|
+
|
|
57
|
+
- [iOS] Add `pickFileAsync` support ([#39173](https://github.com/expo/expo/pull/39173) by [@kosmydel](https://github.com/kosmydel))
|
|
58
|
+
|
|
59
|
+
## 19.0.7 — 2025-08-31
|
|
60
|
+
|
|
61
|
+
### 🎉 New features
|
|
62
|
+
|
|
63
|
+
- Add `rename` method for files and directories ([#39138](https://github.com/expo/expo/pull/39138) by [@kosmydel](https://github.com/kosmydel))
|
|
64
|
+
- Add `idempotent` option for creating directories ([#39121](https://github.com/expo/expo/pull/39121) by [@kosmydel](https://github.com/kosmydel))
|
|
65
|
+
|
|
15
66
|
## 19.0.6 — 2025-08-26
|
|
16
67
|
|
|
17
68
|
_This version does not introduce any user-facing changes._
|
|
@@ -39,6 +90,7 @@ _This version does not introduce any user-facing changes._
|
|
|
39
90
|
### 💡 Others
|
|
40
91
|
|
|
41
92
|
- Update typings for `typescript@5.9` ([#38833](https://github.com/expo/expo/pull/38833) by [@kitten](https://github.com/kitten))
|
|
93
|
+
- Change Constants to Constant/Property. ([#38926](https://github.com/expo/expo/pull/38926) by [@jakex7](https://github.com/jakex7))
|
|
42
94
|
|
|
43
95
|
## 19.0.0 — 2025-08-13
|
|
44
96
|
|
package/android/build.gradle
CHANGED
|
@@ -4,13 +4,13 @@ plugins {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
group = 'host.exp.exponent'
|
|
7
|
-
version = '19.1.0-canary-
|
|
7
|
+
version = '19.1.0-canary-20250919-7a31b96'
|
|
8
8
|
|
|
9
9
|
android {
|
|
10
10
|
namespace "expo.modules.filesystem"
|
|
11
11
|
defaultConfig {
|
|
12
12
|
versionCode 30
|
|
13
|
-
versionName "19.1.0-canary-
|
|
13
|
+
versionName "19.1.0-canary-20250919-7a31b96"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -53,6 +53,9 @@ class FileSystemDirectory(uri: Uri) : FileSystemPath(uri) {
|
|
|
53
53
|
fun create(options: CreateOptions = CreateOptions()) {
|
|
54
54
|
validateType()
|
|
55
55
|
validatePermission(Permission.WRITE)
|
|
56
|
+
if (!needsCreation(options)) {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
56
59
|
validateCanCreate(options)
|
|
57
60
|
if (uri.isContentUri) {
|
|
58
61
|
throw UnableToCreateException("create function does not work with SAF Uris, use `createDirectory` and `createFile` instead")
|
|
@@ -101,4 +104,8 @@ class FileSystemDirectory(uri: Uri) : FileSystemPath(uri) {
|
|
|
101
104
|
val uriString = file.uri.toString()
|
|
102
105
|
return if (uriString.endsWith("/")) uriString else "$uriString/"
|
|
103
106
|
}
|
|
107
|
+
|
|
108
|
+
fun needsCreation(options: CreateOptions): Boolean {
|
|
109
|
+
return !file.exists() || !options.idempotent
|
|
110
|
+
}
|
|
104
111
|
}
|
|
@@ -28,11 +28,17 @@ class FileSystemModule : Module() {
|
|
|
28
28
|
override fun definition() = ModuleDefinition {
|
|
29
29
|
Name("FileSystem")
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
31
|
+
Constant("documentDirectory") {
|
|
32
|
+
Uri.fromFile(context.filesDir).toString() + "/"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Constant("cacheDirectory") {
|
|
36
|
+
Uri.fromFile(context.cacheDir).toString() + "/"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Constant("bundleDirectory") {
|
|
40
|
+
"asset://"
|
|
41
|
+
}
|
|
36
42
|
|
|
37
43
|
Property("totalDiskSpace") {
|
|
38
44
|
File(context.filesDir.path).totalSpace
|
|
@@ -68,7 +74,7 @@ class FileSystemModule : Module() {
|
|
|
68
74
|
to.javaFile
|
|
69
75
|
}
|
|
70
76
|
|
|
71
|
-
if (destination.exists()) {
|
|
77
|
+
if (options?.idempotent != true && destination.exists()) {
|
|
72
78
|
throw DestinationAlreadyExistsException()
|
|
73
79
|
}
|
|
74
80
|
|
|
@@ -12,12 +12,16 @@ data class CreateOptions(
|
|
|
12
12
|
@Field
|
|
13
13
|
val intermediates: Boolean = false,
|
|
14
14
|
@Field
|
|
15
|
-
val overwrite: Boolean = false
|
|
15
|
+
val overwrite: Boolean = false,
|
|
16
|
+
@Field
|
|
17
|
+
val idempotent: Boolean = false
|
|
16
18
|
) : Record
|
|
17
19
|
|
|
18
20
|
data class DownloadOptions(
|
|
19
21
|
@Field
|
|
20
|
-
val headers: Map<String, String> = emptyMap()
|
|
22
|
+
val headers: Map<String, String> = emptyMap(),
|
|
23
|
+
@Field
|
|
24
|
+
val idempotent: Boolean = false
|
|
21
25
|
) : Record
|
|
22
26
|
|
|
23
27
|
data class FileInfo(
|
|
@@ -89,11 +89,17 @@ open class FileSystemLegacyModule : Module() {
|
|
|
89
89
|
override fun definition() = ModuleDefinition {
|
|
90
90
|
Name("ExponentFileSystem")
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
92
|
+
Constant("documentDirectory") {
|
|
93
|
+
Uri.fromFile(context.filesDir).toString() + "/"
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
Constant("cacheDirectory") {
|
|
97
|
+
Uri.fromFile(context.cacheDir).toString() + "/"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Constant("bundleDirectory") {
|
|
101
|
+
"asset:///"
|
|
102
|
+
}
|
|
97
103
|
|
|
98
104
|
Events(
|
|
99
105
|
EXDownloadProgressEventName,
|
|
@@ -1,15 +1,37 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type FileCreateOptions = {
|
|
2
2
|
/**
|
|
3
3
|
* Whether to create intermediate directories if they do not exist.
|
|
4
4
|
* @default false
|
|
5
5
|
*/
|
|
6
6
|
intermediates?: boolean;
|
|
7
7
|
/**
|
|
8
|
-
* Whether to overwrite the file
|
|
8
|
+
* Whether to overwrite the file if it exists.
|
|
9
9
|
* @default false
|
|
10
10
|
*/
|
|
11
11
|
overwrite?: boolean;
|
|
12
12
|
};
|
|
13
|
+
export type DirectoryCreateOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* Whether to create intermediate directories if they do not exist.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
intermediates?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to overwrite the directory if it exists.
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
overwrite?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* This flag controls whether the `create` operation is idempotent
|
|
26
|
+
* (safe to call multiple times without error).
|
|
27
|
+
*
|
|
28
|
+
* If `true`, creating a file or directory that already exists will succeed silently.
|
|
29
|
+
* If `false`, an error will be thrown when the target already exists.
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
idempotent?: boolean;
|
|
34
|
+
};
|
|
13
35
|
export declare class Directory {
|
|
14
36
|
/**
|
|
15
37
|
* Creates an instance of a directory.
|
|
@@ -42,9 +64,9 @@ export declare class Directory {
|
|
|
42
64
|
/**
|
|
43
65
|
* Creates a directory that the current uri points to.
|
|
44
66
|
*
|
|
45
|
-
* @throws Error if the containing folder doesn't exist, the application has no read access to it or the directory (or a file with the same path) already exists.
|
|
67
|
+
* @throws Error if the containing folder doesn't exist, the application has no read access to it or the directory (or a file with the same path) already exists (unless `idempotent` is `true`).
|
|
46
68
|
*/
|
|
47
|
-
create(options?:
|
|
69
|
+
create(options?: DirectoryCreateOptions): void;
|
|
48
70
|
createFile(name: string, mimeType: string | null): File;
|
|
49
71
|
createDirectory(name: string): Directory;
|
|
50
72
|
/**
|
|
@@ -86,9 +108,11 @@ export declare class Directory {
|
|
|
86
108
|
size: number | null;
|
|
87
109
|
/**
|
|
88
110
|
* A static method that opens a file picker to select a directory.
|
|
111
|
+
*
|
|
112
|
+
* On iOS, the selected directory grants temporary read and write access for the current app session only. After the app restarts, you must prompt the user again to regain access.
|
|
113
|
+
*
|
|
89
114
|
* @param initialUri An optional uri pointing to an initial folder on which the directory picker is opened.
|
|
90
|
-
* @returns a `Directory` instance.
|
|
91
|
-
* @platform android
|
|
115
|
+
* @returns a `Directory` instance. On Android, the underlying uri will be a content URI.
|
|
92
116
|
*/
|
|
93
117
|
static pickDirectoryAsync(initialUri?: string): Promise<Directory>;
|
|
94
118
|
}
|
|
@@ -99,6 +123,16 @@ export type DownloadOptions = {
|
|
|
99
123
|
headers?: {
|
|
100
124
|
[key: string]: string;
|
|
101
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* This flag controls whether the `download` operation is idempotent
|
|
128
|
+
* (safe to call multiple times without error).
|
|
129
|
+
*
|
|
130
|
+
* If `true`, downloading a file that already exists overwrites the previous one.
|
|
131
|
+
* If `false`, an error is thrown when the target file already exists.
|
|
132
|
+
*
|
|
133
|
+
* @default false
|
|
134
|
+
*/
|
|
135
|
+
idempotent?: boolean;
|
|
102
136
|
};
|
|
103
137
|
/**
|
|
104
138
|
* Represents a file on the file system.
|
|
@@ -176,7 +210,7 @@ export declare class File {
|
|
|
176
210
|
*
|
|
177
211
|
* @throws Error if the containing folder doesn't exist, the application has no read access to it or the file (or directory with the same path) already exists.
|
|
178
212
|
*/
|
|
179
|
-
create(options?:
|
|
213
|
+
create(options?: FileCreateOptions): void;
|
|
180
214
|
/**
|
|
181
215
|
* Copies a file.
|
|
182
216
|
*/
|
|
@@ -209,16 +243,15 @@ export declare class File {
|
|
|
209
243
|
*/
|
|
210
244
|
static downloadFileAsync(url: string, destination: Directory | File, options?: DownloadOptions): Promise<File>;
|
|
211
245
|
/**
|
|
212
|
-
* A static method that opens a file picker to select a single file of specified type.
|
|
246
|
+
* A static method that opens a file picker to select a single file of specified type. On iOS, it returns a temporary copy of the file leaving the original file untouched.
|
|
213
247
|
*
|
|
214
|
-
*
|
|
248
|
+
* Selecting multiple files is not supported yet.
|
|
215
249
|
*
|
|
216
250
|
* @param initialUri An optional URI pointing to an initial folder on which the file picker is opened.
|
|
217
251
|
* @param mimeType A mime type that is used to filter out files that can be picked out.
|
|
218
|
-
* @returns a `File` instance.
|
|
219
|
-
* @platform android
|
|
252
|
+
* @returns a `File` instance or an array of `File` instances.
|
|
220
253
|
*/
|
|
221
|
-
static pickFileAsync(initialUri?: string, mimeType?: string): Promise<File>;
|
|
254
|
+
static pickFileAsync(initialUri?: string, mimeType?: string): Promise<File | File[]>;
|
|
222
255
|
/**
|
|
223
256
|
* A size of the file in bytes. 0 if the file does not exist, or it cannot be read.
|
|
224
257
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoFileSystem.types.d.ts","sourceRoot":"","sources":["../src/ExpoFileSystem.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"ExpoFileSystem.types.d.ts","sourceRoot":"","sources":["../src/ExpoFileSystem.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B;;;;;;;OAOG;gBACS,GAAG,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE;IAElD;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,YAAY,IAAI,IAAI;IAEpB;;;;OAIG;IACH,MAAM,IAAI,IAAI;IAEd;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,IAAI;IAE9C,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAEvD,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IAExC;;OAEG;IACH,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAEzC;;OAEG;IACH,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,IAAI,GA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AMnC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAItB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare class FileSystemFile {
|
|
2
|
+
constructor();
|
|
3
|
+
}
|
|
4
|
+
declare class FileSystemDirectory {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
declare const _default: {
|
|
8
|
+
FileSystemDirectory: typeof FileSystemDirectory;
|
|
9
|
+
FileSystemFile: typeof FileSystemFile;
|
|
10
|
+
downloadFileAsync: () => Promise<void>;
|
|
11
|
+
pickDirectoryAsync: () => Promise<void>;
|
|
12
|
+
pickFileAsync: () => Promise<void>;
|
|
13
|
+
readonly totalDiskSpace: number;
|
|
14
|
+
readonly availableDiskSpace: number;
|
|
15
|
+
readonly documentDirectory: string;
|
|
16
|
+
readonly cacheDirectory: string;
|
|
17
|
+
readonly bundleDirectory: string;
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
20
|
+
//# sourceMappingURL=ExpoFileSystem.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoFileSystem.web.d.ts","sourceRoot":"","sources":["../src/ExpoFileSystem.web.ts"],"names":[],"mappings":"AAAA,cAAM,cAAc;;CAInB;AAED,cAAM,mBAAmB;;CAIxB;;;;;;;6BAiBuB,MAAM;iCAIF,MAAM;gCAIP,MAAM;6BAIT,MAAM;8BAIL,MAAM;;AA/B/B,wBAmCE"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './FileSystem';
|
|
2
|
-
export { type
|
|
2
|
+
export { type FileCreateOptions, type DirectoryCreateOptions, type FileHandle, type FileInfo, type InfoOptions, type PathInfo, type DirectoryInfo, } from './ExpoFileSystem.types';
|
|
3
|
+
export * from './legacyWarnings';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,aAAa,GACnB,MAAM,wBAAwB,CAAC;AAEhC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { DownloadOptions, FileSystemNetworkTaskProgressCallback, DownloadProgressData, UploadProgressData, FileInfo, FileSystemDownloadResult, FileSystemUploadOptions, FileSystemUploadResult, ReadingOptions, WritingOptions, DeletingOptions, InfoOptions, RelocatingOptions, MakeDirectoryOptions } from './legacy/FileSystem.types';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use `new File().info` or import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getInfoAsync(fileUri: string, options?: InfoOptions): Promise<FileInfo>;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `new File().text()` or import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readAsStringAsync(fileUri: string, options?: ReadingOptions): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getContentUriAsync(fileUri: string): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use `new File().write()` or import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
16
|
+
*/
|
|
17
|
+
export declare function writeAsStringAsync(fileUri: string, contents: string, options?: WritingOptions): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use `new File().delete()` or `new Directory().delete()` or import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
20
|
+
*/
|
|
21
|
+
export declare function deleteAsync(fileUri: string, options?: DeletingOptions): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated
|
|
24
|
+
*/
|
|
25
|
+
export declare function deleteLegacyDocumentDirectoryAndroid(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `new File().move()` or import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
28
|
+
*/
|
|
29
|
+
export declare function moveAsync(options: RelocatingOptions): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Use `new File().copy()` or import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
32
|
+
*/
|
|
33
|
+
export declare function copyAsync(options: RelocatingOptions): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Use `new Directory().create()` or import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
36
|
+
*/
|
|
37
|
+
export declare function makeDirectoryAsync(fileUri: string, options?: MakeDirectoryOptions): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated Use `new Directory().list()` or import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
40
|
+
*/
|
|
41
|
+
export declare function readDirectoryAsync(fileUri: string): Promise<string[]>;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Use `Paths.availableDiskSpace` or import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getFreeDiskStorageAsync(): Promise<number>;
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Use `Paths.totalDiskSpace` or import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
48
|
+
*/
|
|
49
|
+
export declare function getTotalDiskCapacityAsync(): Promise<number>;
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated Use `File.downloadFileAsync` or import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
52
|
+
*/
|
|
53
|
+
export declare function downloadAsync(uri: string, fileUri: string, options?: DownloadOptions): Promise<FileSystemDownloadResult>;
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Use `@expo/fetch` or import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
56
|
+
*/
|
|
57
|
+
export declare function uploadAsync(url: string, fileUri: string, options?: FileSystemUploadOptions): Promise<FileSystemUploadResult>;
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
60
|
+
*/
|
|
61
|
+
export declare function createDownloadResumable(uri: string, fileUri: string, options?: DownloadOptions, callback?: FileSystemNetworkTaskProgressCallback<DownloadProgressData>, resumeData?: string): any;
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated Import this method from `expo-file-system/legacy`. This method will throw in runtime.
|
|
64
|
+
*/
|
|
65
|
+
export declare function createUploadTask(url: string, fileUri: string, options?: FileSystemUploadOptions, callback?: FileSystemNetworkTaskProgressCallback<UploadProgressData>): any;
|
|
66
|
+
//# sourceMappingURL=legacyWarnings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacyWarnings.d.ts","sourceRoot":"","sources":["../src/legacyWarnings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,qCAAqC,EACrC,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,EACR,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAQnC;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEhG;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEzE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;GAEG;AACH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AEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,uBAAuB,EACjC,QAAQ,CAAC,EAAE,qCAAqC,CAAC,kBAAkB,CAAC,GACnE,GAAG,CAEL"}
|
package/expo-module.config.json
CHANGED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// UIKit is unavailable on macOS, so platform checks are necessary.
|
|
2
|
+
// For macOS support, we should consider using NSOpenPanel: https://developer.apple.com/documentation/appkit/nsopenpanel
|
|
3
|
+
// UIDocumentPickerViewController is unavailable on tvOS
|
|
4
|
+
#if os(iOS)
|
|
5
|
+
import ExpoModulesCore
|
|
6
|
+
import UIKit
|
|
7
|
+
|
|
8
|
+
internal class FilePickingHandler: FilePickingResultHandler {
|
|
9
|
+
private weak var module: FileSystemModule?
|
|
10
|
+
internal var filePickingContext: FilePickingContext?
|
|
11
|
+
|
|
12
|
+
init(module: FileSystemModule) {
|
|
13
|
+
self.module = module
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
func presentDocumentPicker(
|
|
17
|
+
picker: UIDocumentPickerViewController,
|
|
18
|
+
isDirectory: Bool,
|
|
19
|
+
initialUri: URL?,
|
|
20
|
+
mimeType: String?,
|
|
21
|
+
promise: Promise
|
|
22
|
+
) {
|
|
23
|
+
guard let module = module else {
|
|
24
|
+
promise.reject(MissingViewControllerException())
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if filePickingContext != nil {
|
|
29
|
+
promise.reject(PickingInProgressException())
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
guard let currentVc = module.appContext?.utilities?.currentViewController() else {
|
|
34
|
+
promise.reject(MissingViewControllerException())
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let pickerDelegate = FilePickingDelegate(resultHandler: self, isDirectory: isDirectory)
|
|
39
|
+
filePickingContext = FilePickingContext(
|
|
40
|
+
promise: promise,
|
|
41
|
+
initialUri: initialUri,
|
|
42
|
+
mimeType: mimeType,
|
|
43
|
+
isDirectory: isDirectory,
|
|
44
|
+
delegate: pickerDelegate
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
picker.delegate = pickerDelegate
|
|
48
|
+
picker.presentationController?.delegate = pickerDelegate
|
|
49
|
+
picker.allowsMultipleSelection = false
|
|
50
|
+
|
|
51
|
+
if UIDevice.current.userInterfaceIdiom == .pad {
|
|
52
|
+
let viewFrame = currentVc.view.frame
|
|
53
|
+
picker.popoverPresentationController?.sourceRect = CGRect(
|
|
54
|
+
x: viewFrame.midX,
|
|
55
|
+
y: viewFrame.maxY,
|
|
56
|
+
width: 0,
|
|
57
|
+
height: 0
|
|
58
|
+
)
|
|
59
|
+
picker.popoverPresentationController?.sourceView = currentVc.view
|
|
60
|
+
picker.modalPresentationStyle = .pageSheet
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
currentVc.present(picker, animated: true)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
func didPickFileAt(url: URL) {
|
|
67
|
+
handlePickingResult { context in
|
|
68
|
+
let file = FileSystemFile(url: url)
|
|
69
|
+
context.promise.resolve(file)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
func didPickDirectoryAt(url: URL) {
|
|
74
|
+
handlePickingResult { context in
|
|
75
|
+
let directory = FileSystemDirectory(url: url)
|
|
76
|
+
context.promise.resolve(directory)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
func didCancelPicking() {
|
|
81
|
+
handlePickingResult { context in
|
|
82
|
+
context.promise.reject(FilePickingCancelledException())
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private func handlePickingResult(_ handler: (FilePickingContext) -> Void) {
|
|
87
|
+
guard let context = filePickingContext else {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
filePickingContext = nil
|
|
91
|
+
|
|
92
|
+
handler(context)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
#endif
|