expo-file-system 19.0.14 → 19.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/filesystem/FileSystemFile.kt +17 -0
  4. package/android/src/main/java/expo/modules/filesystem/{legacy/FileSystemFileProvider.kt → FileSystemFileProvider.kt} +1 -1
  5. package/android/src/main/java/expo/modules/filesystem/FileSystemModule.kt +11 -3
  6. package/android/src/main/java/expo/modules/filesystem/FileSystemNextRecords.kt +14 -1
  7. package/build/ExpoFileSystem.types.d.ts +28 -1
  8. package/build/ExpoFileSystem.types.d.ts.map +1 -1
  9. package/build/FileSystem.d.ts +4 -4
  10. package/expo-module.config.json +1 -1
  11. package/ios/FileSystemExceptions.swift +6 -0
  12. package/ios/FileSystemFile.swift +6 -0
  13. package/ios/FileSystemModule.swift +14 -3
  14. package/ios/FileSystemRecords.swift +10 -0
  15. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{19.0.14/expo.modules.filesystem-19.0.14-sources.jar → 19.0.16/expo.modules.filesystem-19.0.16-sources.jar} +0 -0
  16. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16-sources.jar.md5 +1 -0
  17. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16-sources.jar.sha1 +1 -0
  18. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16-sources.jar.sha256 +1 -0
  19. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16-sources.jar.sha512 +1 -0
  20. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.aar +0 -0
  21. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.aar.md5 +1 -0
  22. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.aar.sha1 +1 -0
  23. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.aar.sha256 +1 -0
  24. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.aar.sha512 +1 -0
  25. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{19.0.14/expo.modules.filesystem-19.0.14.module → 19.0.16/expo.modules.filesystem-19.0.16.module} +22 -22
  26. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.module.md5 +1 -0
  27. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.module.sha1 +1 -0
  28. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.module.sha256 +1 -0
  29. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.module.sha512 +1 -0
  30. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{19.0.14/expo.modules.filesystem-19.0.14.pom → 19.0.16/expo.modules.filesystem-19.0.16.pom} +1 -1
  31. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.pom.md5 +1 -0
  32. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.pom.sha1 +1 -0
  33. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.pom.sha256 +1 -0
  34. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.16/expo.modules.filesystem-19.0.16.pom.sha512 +1 -0
  35. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml +4 -4
  36. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.md5 +1 -1
  37. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha1 +1 -1
  38. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha256 +1 -1
  39. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha512 +1 -1
  40. package/package.json +3 -3
  41. package/src/ExpoFileSystem.types.ts +30 -1
  42. package/src/FileSystem.ts +4 -4
  43. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14-sources.jar.md5 +0 -1
  44. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14-sources.jar.sha1 +0 -1
  45. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14-sources.jar.sha256 +0 -1
  46. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14-sources.jar.sha512 +0 -1
  47. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.aar +0 -0
  48. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.aar.md5 +0 -1
  49. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.aar.sha1 +0 -1
  50. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.aar.sha256 +0 -1
  51. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.aar.sha512 +0 -1
  52. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.module.md5 +0 -1
  53. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.module.sha1 +0 -1
  54. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.module.sha256 +0 -1
  55. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.module.sha512 +0 -1
  56. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.pom.md5 +0 -1
  57. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.pom.sha1 +0 -1
  58. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.pom.sha256 +0 -1
  59. package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.14/expo.modules.filesystem-19.0.14.pom.sha512 +0 -1
  60. /package/android/src/main/{java/expo/modules/filesystem/AndroidManifest.xml → AndroidManifest.xml} +0 -0
package/CHANGELOG.md CHANGED
@@ -10,6 +10,23 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 19.0.16 — 2025-10-01
14
+
15
+ ### 🎉 New features
16
+
17
+ - Add write options for base64 encoded bytes. ([#39963](https://github.com/expo/expo/pull/39963) by [@aleqsio](https://github.com/aleqsio))
18
+
19
+ ### 🐛 Bug fixes
20
+
21
+ - Fix typedoc in the File class. ([#40064](https://github.com/expo/expo/pull/40064) by [@aleqsio](https://github.com/aleqsio))
22
+ - [Android] Fix getContentUri. ([#40001](https://github.com/expo/expo/pull/40001) by [@aleqsio](https://github.com/aleqsio))
23
+
24
+ ## 19.0.15 — 2025-09-22
25
+
26
+ ### 🎉 New features
27
+
28
+ - add `idempotent` option to `downloadFileAsync` ([#39681](https://github.com/expo/expo/pull/39681) by [@vonovak](https://github.com/vonovak))
29
+
13
30
  ## 19.0.14 — 2025-09-13
14
31
 
15
32
  _This version does not introduce any user-facing changes._
@@ -4,13 +4,13 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'host.exp.exponent'
7
- version = '19.0.14'
7
+ version = '19.0.16'
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.filesystem"
11
11
  defaultConfig {
12
12
  versionCode 30
13
- versionName "19.0.14"
13
+ versionName "19.0.16"
14
14
  }
15
15
  }
16
16
 
@@ -80,6 +80,23 @@ class FileSystemFile(uri: Uri) : FileSystemPath(uri) {
80
80
  }
81
81
  }
82
82
 
83
+ fun write(content: ByteArray) {
84
+ validateType()
85
+ validatePermission(Permission.WRITE)
86
+ if (!exists) {
87
+ create()
88
+ }
89
+ if (uri.isContentUri) {
90
+ file.outputStream().use { outputStream ->
91
+ outputStream.write(content)
92
+ }
93
+ } else {
94
+ FileOutputStream(javaFile).use {
95
+ it.write(content)
96
+ }
97
+ }
98
+ }
99
+
83
100
  fun asString(): String {
84
101
  val uriString = file.uri.toString()
85
102
  return if (uriString.endsWith("/")) uriString.dropLast(1) else uriString
@@ -1,4 +1,4 @@
1
- package expo.modules.filesystem.legacy
1
+ package expo.modules.filesystem
2
2
 
3
3
  import androidx.core.content.FileProvider
4
4
 
@@ -2,7 +2,10 @@ package expo.modules.filesystem
2
2
 
3
3
  import android.content.Context
4
4
  import android.net.Uri
5
+ import android.os.Build
6
+ import android.util.Base64
5
7
  import android.webkit.URLUtil
8
+ import androidx.annotation.RequiresApi
6
9
  import expo.modules.interfaces.filesystem.Permission
7
10
  import expo.modules.kotlin.activityresult.AppContextActivityResultLauncher
8
11
  import expo.modules.kotlin.apifeatures.EitherType
@@ -24,6 +27,7 @@ class FileSystemModule : Module() {
24
27
  private val context: Context
25
28
  get() = appContext.reactContext ?: throw Exceptions.AppContextLost()
26
29
 
30
+ @RequiresApi(Build.VERSION_CODES.O)
27
31
  @OptIn(EitherType::class)
28
32
  override fun definition() = ModuleDefinition {
29
33
  Name("FileSystem")
@@ -74,7 +78,7 @@ class FileSystemModule : Module() {
74
78
  to.javaFile
75
79
  }
76
80
 
77
- if (destination.exists()) {
81
+ if (options?.idempotent != true && destination.exists()) {
78
82
  throw DestinationAlreadyExistsException()
79
83
  }
80
84
 
@@ -138,10 +142,14 @@ class FileSystemModule : Module() {
138
142
  file.create(options ?: CreateOptions())
139
143
  }
140
144
 
141
- Function("write") { file: FileSystemFile, content: Either<String, TypedArray> ->
145
+ Function("write") { file: FileSystemFile, content: Either<String, TypedArray>, options: WriteOptions? ->
142
146
  if (content.`is`(String::class)) {
143
147
  content.get(String::class).let {
144
- file.write(it)
148
+ if (options?.encoding == EncodingType.BASE64) {
149
+ file.write(Base64.decode(it, Base64.DEFAULT))
150
+ } else {
151
+ file.write(it)
152
+ }
145
153
  }
146
154
  }
147
155
  if (content.`is`(TypedArray::class)) {
@@ -2,6 +2,7 @@ package expo.modules.filesystem
2
2
 
3
3
  import expo.modules.kotlin.records.Field
4
4
  import expo.modules.kotlin.records.Record
5
+ import expo.modules.kotlin.types.Enumerable
5
6
 
6
7
  data class InfoOptions(
7
8
  @Field
@@ -17,9 +18,21 @@ data class CreateOptions(
17
18
  val idempotent: Boolean = false
18
19
  ) : Record
19
20
 
21
+ enum class EncodingType(val value: String) : Enumerable {
22
+ UTF8("utf8"),
23
+ BASE64("base64")
24
+ }
25
+
26
+ data class WriteOptions(
27
+ @Field
28
+ val encoding: EncodingType = EncodingType.UTF8
29
+ ) : Record
30
+
20
31
  data class DownloadOptions(
21
32
  @Field
22
- val headers: Map<String, String> = emptyMap()
33
+ val headers: Map<String, String> = emptyMap(),
34
+ @Field
35
+ val idempotent: Boolean = false
23
36
  ) : Record
24
37
 
25
38
  data class FileInfo(
@@ -10,6 +10,23 @@ export type FileCreateOptions = {
10
10
  */
11
11
  overwrite?: boolean;
12
12
  };
13
+ export declare enum EncodingType {
14
+ /**
15
+ * Standard encoding format.
16
+ */
17
+ UTF8 = "utf8",
18
+ /**
19
+ * Binary, radix-64 representation.
20
+ */
21
+ Base64 = "base64"
22
+ }
23
+ export type FileWriteOptions = {
24
+ /**
25
+ * The encoding format to use when writing the file.
26
+ * @default FileSystem.EncodingType.UTF8
27
+ */
28
+ encoding?: EncodingType | 'utf8' | 'base64';
29
+ };
13
30
  export type DirectoryCreateOptions = {
14
31
  /**
15
32
  * Whether to create intermediate directories if they do not exist.
@@ -123,6 +140,16 @@ export type DownloadOptions = {
123
140
  headers?: {
124
141
  [key: string]: string;
125
142
  };
143
+ /**
144
+ * This flag controls whether the `download` operation is idempotent
145
+ * (safe to call multiple times without error).
146
+ *
147
+ * If `true`, downloading a file that already exists overwrites the previous one.
148
+ * If `false`, an error is thrown when the target file already exists.
149
+ *
150
+ * @default false
151
+ */
152
+ idempotent?: boolean;
126
153
  };
127
154
  /**
128
155
  * Represents a file on the file system.
@@ -177,7 +204,7 @@ export declare class File {
177
204
  * Writes content to the file.
178
205
  * @param content The content to write into the file.
179
206
  */
180
- write(content: string | Uint8Array): void;
207
+ write(content: string | Uint8Array, options: FileWriteOptions): void;
181
208
  /**
182
209
  * Deletes a file.
183
210
  *
@@ -1 +1 @@
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,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,MAAM,CAAC,OAAO,OAAO,UAAU;IAI7B,KAAK,IAAI,IAAI;IAKb,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC;IAKlD,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAMnC,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"}
@@ -36,7 +36,7 @@ export declare class Paths extends PathUtilities {
36
36
  * The constructor accepts an array of strings that are joined to create the file URI. The first argument can also be a `Directory` instance (like `Paths.cache`) or a `File` instance (which creates a new reference to the same file).
37
37
  * @example
38
38
  * ```ts
39
- * const file = new File(File.cache, "subdirName", "file.txt");
39
+ * const file = new File(Paths.cache, "subdirName", "file.txt");
40
40
  * ```
41
41
  */
42
42
  export declare class File extends ExpoFileSystem.FileSystemFile implements Blob {
@@ -47,7 +47,7 @@ export declare class File extends ExpoFileSystem.FileSystemFile implements Blob
47
47
  * @param uris An array of: `file:///` string URIs, `File` instances, and `Directory` instances representing an arbitrary location on the file system.
48
48
  * @example
49
49
  * ```ts
50
- * const file = new File(File.cache, "subdirName", "file.txt");
50
+ * const file = new File(Paths.cache, "subdirName", "file.txt");
51
51
  * ```
52
52
  */
53
53
  constructor(...uris: (string | File | Directory)[]);
@@ -75,7 +75,7 @@ export declare class File extends ExpoFileSystem.FileSystemFile implements Blob
75
75
  * The constructor accepts an array of strings that are joined to create the directory URI. The first argument can also be a `Directory` instance (like `Paths.cache`).
76
76
  * @example
77
77
  * ```ts
78
- * const directory = new Directory(File.cache, "subdirName");
78
+ * const directory = new Directory(Paths.cache, "subdirName");
79
79
  * ```
80
80
  */
81
81
  export declare class Directory extends ExpoFileSystem.FileSystemDirectory {
@@ -86,7 +86,7 @@ export declare class Directory extends ExpoFileSystem.FileSystemDirectory {
86
86
  * @param uris An array of: `file:///` string URIs, `File` instances, and `Directory` instances representing an arbitrary location on the file system.
87
87
  * @example
88
88
  * ```ts
89
- * const directory = new Directory(File.cache, "subdirName");
89
+ * const directory = new Directory(Paths.cache, "subdirName");
90
90
  * ```
91
91
  */
92
92
  constructor(...uris: (string | File | Directory)[]);
@@ -12,7 +12,7 @@
12
12
  "publication": {
13
13
  "groupId": "host.exp.exponent",
14
14
  "artifactId": "expo.modules.filesystem",
15
- "version": "19.0.14",
15
+ "version": "19.0.16",
16
16
  "repository": "local-maven-repo"
17
17
  }
18
18
  }
@@ -13,6 +13,12 @@ internal final class UnableToDownloadException: GenericException<String> {
13
13
  }
14
14
  }
15
15
 
16
+ internal final class UnableToWriteBase64DataException: GenericException<String> {
17
+ override var reason: String {
18
+ "Unable to write base64 data to a file: \(param)"
19
+ }
20
+ }
21
+
16
22
  internal final class InvalidTypeFileException: Exception {
17
23
  override var reason: String {
18
24
  "A folder with the same name already exists in the file location"
@@ -81,6 +81,12 @@ internal final class FileSystemFile: FileSystemPath {
81
81
  }
82
82
  }
83
83
 
84
+ func write(_ data: Data) throws {
85
+ try withCorrectTypeAndScopedAccess(permission: .write) {
86
+ try data.write(to: url)
87
+ }
88
+ }
89
+
84
90
  // TODO: blob support
85
91
  func write(_ content: TypedArray) throws {
86
92
  try withCorrectTypeAndScopedAccess(permission: .write) {
@@ -94,7 +94,11 @@ public final class FileSystemModule: Module {
94
94
  destination = to.url
95
95
  }
96
96
  if FileManager.default.fileExists(atPath: destination.path) {
97
- throw DestinationAlreadyExistsException()
97
+ if options?.idempotent == true {
98
+ try FileManager.default.removeItem(at: destination)
99
+ } else {
100
+ throw DestinationAlreadyExistsException()
101
+ }
98
102
  }
99
103
  try FileManager.default.moveItem(at: fileURL, to: destination)
100
104
  // TODO: Remove .url.absoluteString once returning shared objects works
@@ -198,9 +202,16 @@ public final class FileSystemModule: Module {
198
202
  return try file.info(options: options ?? InfoOptions())
199
203
  }
200
204
 
201
- Function("write") { (file, content: Either<String, TypedArray>) in
205
+ Function("write") { (file: FileSystemFile, content: Either<String, TypedArray>, options: WriteOptions?) in
202
206
  if let content: String = content.get() {
203
- try file.write(content)
207
+ if options?.encoding == WriteEncoding.base64 {
208
+ guard let data = Data(base64Encoded: content, options: .ignoreUnknownCharacters) else {
209
+ throw UnableToWriteBase64DataException(file.url.absoluteString)
210
+ }
211
+ try file.write(data)
212
+ } else {
213
+ try file.write(content)
214
+ }
204
215
  }
205
216
  if let content: TypedArray = content.get() {
206
217
  try file.write(content)
@@ -10,6 +10,7 @@ struct CreateOptions: Record {
10
10
 
11
11
  struct DownloadOptions: Record {
12
12
  @Field var headers: [String: String]?
13
+ @Field var idempotent: Bool = false
13
14
  }
14
15
 
15
16
  struct FileInfo: Record {
@@ -34,3 +35,12 @@ struct DirectoryInfo: Record {
34
35
  @Field var modificationTime: Int64?
35
36
  @Field var creationTime: Int64?
36
37
  }
38
+
39
+ enum WriteEncoding: String, Enumerable {
40
+ case utf8
41
+ case base64
42
+ }
43
+
44
+ struct WriteOptions: Record {
45
+ @Field var encoding: WriteEncoding?
46
+ }
@@ -0,0 +1 @@
1
+ 2ce5bf618d3e1370e92da41b3ae54847ee10874310bac1c7a31918ea9b463777
@@ -0,0 +1 @@
1
+ 60c1582dab4e6504250846af398e2e5993b17a7c14c141282407f8f7f7949256331d238c5ea32afb7c5753903fc0b868fe1a79c3f972ea2525e947744005c6dc
@@ -0,0 +1 @@
1
+ feab8d53caa9bbf48cf41532048ac5f206b0ab482118d2279a5124126902b9fa
@@ -0,0 +1 @@
1
+ c6a7ae1fb95df6076dd160993ce6650502806e924f35b7e87fa03f0f6060bc7db14f7a603692ce8b880f84462404d59dd8129b486a1e732c5b9d1cc4c255440d
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "host.exp.exponent",
5
5
  "module": "expo.modules.filesystem",
6
- "version": "19.0.14",
6
+ "version": "19.0.16",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -75,13 +75,13 @@
75
75
  ],
76
76
  "files": [
77
77
  {
78
- "name": "expo.modules.filesystem-19.0.14.aar",
79
- "url": "expo.modules.filesystem-19.0.14.aar",
80
- "size": 386425,
81
- "sha512": "8c00661df12bf3a0124f5bab782d544bef6a0f06340ac9f86c2d3f2c5384d542c242dce0d832f9960da4adb5cd7bbb576bd8fa55a6de439890ee7403efd08fe3",
82
- "sha256": "24ecb7d1223c1ed7b11208f7ba90b688b68f69316b557aa53fa4850560eff347",
83
- "sha1": "d6f2c0f72cd8798791ef0c2427a8dc27451d1c49",
84
- "md5": "393ebd0bb15c84c2251df0dba55049b4"
78
+ "name": "expo.modules.filesystem-19.0.16.aar",
79
+ "url": "expo.modules.filesystem-19.0.16.aar",
80
+ "size": 390234,
81
+ "sha512": "c6a7ae1fb95df6076dd160993ce6650502806e924f35b7e87fa03f0f6060bc7db14f7a603692ce8b880f84462404d59dd8129b486a1e732c5b9d1cc4c255440d",
82
+ "sha256": "feab8d53caa9bbf48cf41532048ac5f206b0ab482118d2279a5124126902b9fa",
83
+ "sha1": "b75600742761aa7454e90367911205a044962027",
84
+ "md5": "87d735cdcd4a073816bf205bbf6dbe7c"
85
85
  }
86
86
  ]
87
87
  },
@@ -153,13 +153,13 @@
153
153
  ],
154
154
  "files": [
155
155
  {
156
- "name": "expo.modules.filesystem-19.0.14.aar",
157
- "url": "expo.modules.filesystem-19.0.14.aar",
158
- "size": 386425,
159
- "sha512": "8c00661df12bf3a0124f5bab782d544bef6a0f06340ac9f86c2d3f2c5384d542c242dce0d832f9960da4adb5cd7bbb576bd8fa55a6de439890ee7403efd08fe3",
160
- "sha256": "24ecb7d1223c1ed7b11208f7ba90b688b68f69316b557aa53fa4850560eff347",
161
- "sha1": "d6f2c0f72cd8798791ef0c2427a8dc27451d1c49",
162
- "md5": "393ebd0bb15c84c2251df0dba55049b4"
156
+ "name": "expo.modules.filesystem-19.0.16.aar",
157
+ "url": "expo.modules.filesystem-19.0.16.aar",
158
+ "size": 390234,
159
+ "sha512": "c6a7ae1fb95df6076dd160993ce6650502806e924f35b7e87fa03f0f6060bc7db14f7a603692ce8b880f84462404d59dd8129b486a1e732c5b9d1cc4c255440d",
160
+ "sha256": "feab8d53caa9bbf48cf41532048ac5f206b0ab482118d2279a5124126902b9fa",
161
+ "sha1": "b75600742761aa7454e90367911205a044962027",
162
+ "md5": "87d735cdcd4a073816bf205bbf6dbe7c"
163
163
  }
164
164
  ]
165
165
  },
@@ -173,13 +173,13 @@
173
173
  },
174
174
  "files": [
175
175
  {
176
- "name": "expo.modules.filesystem-19.0.14-sources.jar",
177
- "url": "expo.modules.filesystem-19.0.14-sources.jar",
178
- "size": 28550,
179
- "sha512": "b8f0a84aa8f6377f6fb162699e663d8e9de63caff453a37513e1cfeeaaa050261f8ae32032f15e8968e8591d518531d46e8e549c745b2998ee16fc7578903872",
180
- "sha256": "267e88a3c5d6745c834050282f9a45c0305f51c7b8554e18e0b68a16ab337edb",
181
- "sha1": "1c9d91c71b0534cc4967a352ccb7864aa71054c1",
182
- "md5": "792cb40c62c2c908a410b672981f14b0"
176
+ "name": "expo.modules.filesystem-19.0.16-sources.jar",
177
+ "url": "expo.modules.filesystem-19.0.16-sources.jar",
178
+ "size": 28785,
179
+ "sha512": "60c1582dab4e6504250846af398e2e5993b17a7c14c141282407f8f7f7949256331d238c5ea32afb7c5753903fc0b868fe1a79c3f972ea2525e947744005c6dc",
180
+ "sha256": "2ce5bf618d3e1370e92da41b3ae54847ee10874310bac1c7a31918ea9b463777",
181
+ "sha1": "d372fc4ea514b436e89656c186c54f3c27320b7e",
182
+ "md5": "eb9c254f5ab2514e83db9dd934eaa22c"
183
183
  }
184
184
  ]
185
185
  }
@@ -0,0 +1 @@
1
+ dbc438671dad3d9ecc355bb0a26971e115bd4aa098c41cdd9e86d69053b90f88
@@ -0,0 +1 @@
1
+ 5924747e355b59660367ab020f805afbea65b5f506f6673a9f06cac9343b362c472c4d96588a97944393b9cec3f75271c1a8aa516097f475985badc7944b6c1b
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>host.exp.exponent</groupId>
11
11
  <artifactId>expo.modules.filesystem</artifactId>
12
- <version>19.0.14</version>
12
+ <version>19.0.16</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.filesystem</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ 9fd2cff40ef53e89777a2dc995002720fb7e374e2fa808b903802961746178ba
@@ -0,0 +1 @@
1
+ 5ee2686dec6aa95c7e1a8de47a63033bdf696758808744e079a151f3e390242b9cf7c66985a92b8e36c81d0b5ff4508fd7311929029668098c017f9cb9e33285
@@ -3,11 +3,11 @@
3
3
  <groupId>host.exp.exponent</groupId>
4
4
  <artifactId>expo.modules.filesystem</artifactId>
5
5
  <versioning>
6
- <latest>19.0.14</latest>
7
- <release>19.0.14</release>
6
+ <latest>19.0.16</latest>
7
+ <release>19.0.16</release>
8
8
  <versions>
9
- <version>19.0.14</version>
9
+ <version>19.0.16</version>
10
10
  </versions>
11
- <lastUpdated>20250913004535</lastUpdated>
11
+ <lastUpdated>20251001002202</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- a333767b64e790cef5812ef36ff1a53c
1
+ 70816adde62d1cabb634f2d24c390556
@@ -1 +1 @@
1
- 20b88d8f4e94ebc41ef40424b0f23fbf7522c207
1
+ 8e488291cf4e0ddf1a2bb0b1e43c507b4c05150b
@@ -1 +1 @@
1
- 0a4d02a5cdb1644d8dc7d2b60aa3cb1ed6621bca577402f87cd1f5a43078596f
1
+ 182697a7c3a5a66cc3676be5ea1e4114c8efb000bf682749bcbfc47b53228257
@@ -1 +1 @@
1
- 8c0a3b7144ba617e6fb2a364f07bcc71b01cf9d889f1a2bae10ee35cc4cdd096a3dc31c5f9a12a515273acd4c4229b0554847e4b27796f24bcc72d5c5b893571
1
+ af9e7e36960251e4ad9d0ab63105464bcb20251ede5c2705c7f1e80eb07371a9087c9610624f97c4b5e23c5a3a766db5dcf99ee0f6b89aa2b9e54b8d48a15c52
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-file-system",
3
- "version": "19.0.14",
3
+ "version": "19.0.16",
4
4
  "description": "Provides access to the local file system on the device.",
5
5
  "main": "src/index.ts",
6
6
  "types": "build/index.d.ts",
@@ -36,11 +36,11 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "expo-module-scripts": "^5.0.7",
39
- "jest-expo": "~54.0.11"
39
+ "jest-expo": "~54.0.12"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "expo": "*",
43
43
  "react-native": "*"
44
44
  },
45
- "gitHead": "c59b0b711af9b43cf17abe7613ce1c2f42808ec3"
45
+ "gitHead": "1ab3b9621b78b77b81049ebf06149753a1e0898c"
46
46
  }
@@ -11,6 +11,25 @@ export type FileCreateOptions = {
11
11
  overwrite?: boolean;
12
12
  };
13
13
 
14
+ export enum EncodingType {
15
+ /**
16
+ * Standard encoding format.
17
+ */
18
+ UTF8 = 'utf8',
19
+ /**
20
+ * Binary, radix-64 representation.
21
+ */
22
+ Base64 = 'base64',
23
+ }
24
+
25
+ export type FileWriteOptions = {
26
+ /**
27
+ * The encoding format to use when writing the file.
28
+ * @default FileSystem.EncodingType.UTF8
29
+ */
30
+ encoding?: EncodingType | 'utf8' | 'base64';
31
+ };
32
+
14
33
  export type DirectoryCreateOptions = {
15
34
  /**
16
35
  * Whether to create intermediate directories if they do not exist.
@@ -138,6 +157,16 @@ export type DownloadOptions = {
138
157
  headers?: {
139
158
  [key: string]: string;
140
159
  };
160
+ /**
161
+ * This flag controls whether the `download` operation is idempotent
162
+ * (safe to call multiple times without error).
163
+ *
164
+ * If `true`, downloading a file that already exists overwrites the previous one.
165
+ * If `false`, an error is thrown when the target file already exists.
166
+ *
167
+ * @default false
168
+ */
169
+ idempotent?: boolean;
141
170
  };
142
171
 
143
172
  /**
@@ -202,7 +231,7 @@ export declare class File {
202
231
  * Writes content to the file.
203
232
  * @param content The content to write into the file.
204
233
  */
205
- write(content: string | Uint8Array): void;
234
+ write(content: string | Uint8Array, options: FileWriteOptions): void;
206
235
 
207
236
  /**
208
237
  * Deletes a file.
package/src/FileSystem.ts CHANGED
@@ -65,7 +65,7 @@ export class Paths extends PathUtilities {
65
65
  * The constructor accepts an array of strings that are joined to create the file URI. The first argument can also be a `Directory` instance (like `Paths.cache`) or a `File` instance (which creates a new reference to the same file).
66
66
  * @example
67
67
  * ```ts
68
- * const file = new File(File.cache, "subdirName", "file.txt");
68
+ * const file = new File(Paths.cache, "subdirName", "file.txt");
69
69
  * ```
70
70
  */
71
71
  export class File extends ExpoFileSystem.FileSystemFile implements Blob {
@@ -76,7 +76,7 @@ export class File extends ExpoFileSystem.FileSystemFile implements Blob {
76
76
  * @param uris An array of: `file:///` string URIs, `File` instances, and `Directory` instances representing an arbitrary location on the file system.
77
77
  * @example
78
78
  * ```ts
79
- * const file = new File(File.cache, "subdirName", "file.txt");
79
+ * const file = new File(Paths.cache, "subdirName", "file.txt");
80
80
  * ```
81
81
  */
82
82
  constructor(...uris: (string | File | Directory)[]) {
@@ -151,7 +151,7 @@ File.pickFileAsync = async function (initialUri?: string, mimeType?: string) {
151
151
  * The constructor accepts an array of strings that are joined to create the directory URI. The first argument can also be a `Directory` instance (like `Paths.cache`).
152
152
  * @example
153
153
  * ```ts
154
- * const directory = new Directory(File.cache, "subdirName");
154
+ * const directory = new Directory(Paths.cache, "subdirName");
155
155
  * ```
156
156
  */
157
157
  export class Directory extends ExpoFileSystem.FileSystemDirectory {
@@ -162,7 +162,7 @@ export class Directory extends ExpoFileSystem.FileSystemDirectory {
162
162
  * @param uris An array of: `file:///` string URIs, `File` instances, and `Directory` instances representing an arbitrary location on the file system.
163
163
  * @example
164
164
  * ```ts
165
- * const directory = new Directory(File.cache, "subdirName");
165
+ * const directory = new Directory(Paths.cache, "subdirName");
166
166
  * ```
167
167
  */
168
168
  constructor(...uris: (string | File | Directory)[]) {
@@ -1 +0,0 @@
1
- 267e88a3c5d6745c834050282f9a45c0305f51c7b8554e18e0b68a16ab337edb
@@ -1 +0,0 @@
1
- b8f0a84aa8f6377f6fb162699e663d8e9de63caff453a37513e1cfeeaaa050261f8ae32032f15e8968e8591d518531d46e8e549c745b2998ee16fc7578903872
@@ -1 +0,0 @@
1
- 24ecb7d1223c1ed7b11208f7ba90b688b68f69316b557aa53fa4850560eff347
@@ -1 +0,0 @@
1
- 8c00661df12bf3a0124f5bab782d544bef6a0f06340ac9f86c2d3f2c5384d542c242dce0d832f9960da4adb5cd7bbb576bd8fa55a6de439890ee7403efd08fe3
@@ -1 +0,0 @@
1
- eecf5516375a4abc683cacd8e33d0edb519a35ebab73b241eaafbed6219e0054
@@ -1 +0,0 @@
1
- 116448828814b6d0bcd937277454728e24c190c87395ef81141e69d107a391e0246ea6e0d43fe897c2142ea762a713f487ac6db598ff5b4b85ac63b3b732ca3b
@@ -1 +0,0 @@
1
- f5f7c4bc990af9cd2105e939e55c724ddc69973731d948631236d4efb4a0e226
@@ -1 +0,0 @@
1
- 7cb5ca682959a4fdfd8a14127e912e06ed0bf11699f97afff790354a9b3d0ef0dad39ff7314f85f3b41b1bca9dec0b82b0abd6e665a11adb9857846324f4a3ab