expo-file-system 19.0.1 → 19.0.3
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 +11 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/filesystem/FilePickerContract.kt +71 -0
- package/android/src/main/java/expo/modules/filesystem/FileSystemExceptions.kt +2 -4
- package/android/src/main/java/expo/modules/filesystem/FileSystemModule.kt +26 -1
- package/android/src/main/java/expo/modules/filesystem/FileSystemPath.kt +11 -0
- package/android/src/main/java/expo/modules/filesystem/unifiedfile/AssetFile.kt +121 -0
- package/android/src/main/java/expo/modules/filesystem/unifiedfile/SAFDocumentFile.kt +25 -14
- package/build/ExpoFileSystem.d.ts +5 -0
- package/build/ExpoFileSystem.d.ts.map +1 -1
- package/build/ExpoFileSystem.types.d.ts +16 -1
- package/build/ExpoFileSystem.types.d.ts.map +1 -1
- package/build/FileSystem.d.ts.map +1 -1
- package/expo-module.config.json +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{19.0.1/expo.modules.filesystem-19.0.1-sources.jar → 19.0.3/expo.modules.filesystem-19.0.3-sources.jar} +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{19.0.1/expo.modules.filesystem-19.0.1.module → 19.0.3/expo.modules.filesystem-19.0.3.module} +22 -22
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{19.0.1/expo.modules.filesystem-19.0.1.pom → 19.0.3/expo.modules.filesystem-19.0.3.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.3/expo.modules.filesystem-19.0.3.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/package.json +4 -4
- package/src/ExpoFileSystem.ts +5 -0
- package/src/ExpoFileSystem.types.ts +18 -1
- package/src/FileSystem.ts +11 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/19.0.1/expo.modules.filesystem-19.0.1.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 19.0.3 — 2025-08-18
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fixed type definition for `textSync()` to return `string` instead of `Promise<string>` ([#38898](https://github.com/expo/expo/pull/38898) by [@LeonDvlpmnt](https://github.com/LeonDvlpmnt))
|
|
18
|
+
|
|
19
|
+
## 19.0.2 — 2025-08-16
|
|
20
|
+
|
|
21
|
+
_This version does not introduce any user-facing changes._
|
|
22
|
+
|
|
13
23
|
## 19.0.1 — 2025-08-15
|
|
14
24
|
|
|
15
25
|
### 💡 Others
|
|
@@ -24,6 +34,7 @@
|
|
|
24
34
|
|
|
25
35
|
### 🎉 New features
|
|
26
36
|
|
|
37
|
+
- [android] Add file and directory pickers. ([#38455](https://github.com/expo/expo/pull/38455) by [@aleqsio](https://github.com/aleqsio))
|
|
27
38
|
- Add support for asset uris. ([#38785](https://github.com/expo/expo/pull/38785) by [@aleqsio](https://github.com/aleqsio))
|
|
28
39
|
- Make file implement blob interface directly. ([#38160](https://github.com/expo/expo/pull/38160) by [@aleqsio](https://github.com/aleqsio))
|
|
29
40
|
- Add directory info function ([#37910](https://github.com/expo/expo/pull/37910) by [@Wenszel](https://github.com/Wenszel))
|
package/android/build.gradle
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
package expo.modules.filesystem
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.app.Activity
|
|
5
|
+
import android.content.ContentResolver
|
|
6
|
+
import android.content.Context
|
|
7
|
+
import android.content.Intent
|
|
8
|
+
import android.net.Uri
|
|
9
|
+
import android.os.Build
|
|
10
|
+
import android.provider.DocumentsContract
|
|
11
|
+
import expo.modules.kotlin.activityresult.AppContextActivityResultContract
|
|
12
|
+
import expo.modules.kotlin.providers.AppContextProvider
|
|
13
|
+
import java.io.Serializable
|
|
14
|
+
|
|
15
|
+
@SuppressLint("WrongConstant")
|
|
16
|
+
internal class FilePickerContract(private val appContextProvider: AppContextProvider) : AppContextActivityResultContract<FilePickerContractOptions, FilePickerContractResult> {
|
|
17
|
+
private val contentResolver: ContentResolver
|
|
18
|
+
get() = requireNotNull(appContextProvider.appContext.reactContext) {
|
|
19
|
+
"React Application Context is null"
|
|
20
|
+
}.contentResolver
|
|
21
|
+
|
|
22
|
+
override fun createIntent(context: Context, input: FilePickerContractOptions): Intent =
|
|
23
|
+
if (input.pickerType == PickerType.FILE) {
|
|
24
|
+
Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
|
|
25
|
+
// if no type is set no intent handler is found – just android things
|
|
26
|
+
type = input.mimeType ?: "*/*"
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
|
30
|
+
}.also { intent ->
|
|
31
|
+
// intent.addCategory(Intent.CATEGORY_OPENABLE)
|
|
32
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
33
|
+
input.initialUri.let { intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, it) }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override fun parseResult(input: FilePickerContractOptions, resultCode: Int, intent: Intent?): FilePickerContractResult =
|
|
38
|
+
if (resultCode == Activity.RESULT_CANCELED || intent == null) {
|
|
39
|
+
FilePickerContractResult.Cancelled
|
|
40
|
+
} else {
|
|
41
|
+
val uri = intent.data
|
|
42
|
+
val takeFlags = (intent.flags.and((Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)))
|
|
43
|
+
uri?.let {
|
|
44
|
+
contentResolver.takePersistableUriPermission(it, takeFlags)
|
|
45
|
+
}
|
|
46
|
+
when (input.pickerType) {
|
|
47
|
+
PickerType.DIRECTORY -> FilePickerContractResult.Success(
|
|
48
|
+
FileSystemDirectory(
|
|
49
|
+
uri
|
|
50
|
+
?: Uri.EMPTY
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
PickerType.FILE -> {
|
|
55
|
+
FilePickerContractResult.Success(FileSystemFile(uri ?: Uri.EMPTY))
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
internal data class FilePickerContractOptions(val initialUri: Uri?, val mimeType: String? = null, val pickerType: PickerType = PickerType.FILE) : Serializable
|
|
62
|
+
|
|
63
|
+
internal enum class PickerType {
|
|
64
|
+
FILE,
|
|
65
|
+
DIRECTORY
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
internal sealed class FilePickerContractResult {
|
|
69
|
+
class Success(val path: FileSystemPath) : FilePickerContractResult()
|
|
70
|
+
object Cancelled : FilePickerContractResult()
|
|
71
|
+
}
|
|
@@ -44,10 +44,8 @@ internal class UnableToWriteHandleException(reason: String) :
|
|
|
44
44
|
"Unable to write to a file handle: '$reason'"
|
|
45
45
|
)
|
|
46
46
|
|
|
47
|
-
internal class
|
|
48
|
-
CodedException(
|
|
49
|
-
"Unable to get info from a file: '$reason'"
|
|
50
|
-
)
|
|
47
|
+
internal class PickerCancelledException :
|
|
48
|
+
CodedException("The file picker was cancelled by the user")
|
|
51
49
|
|
|
52
50
|
internal class DestinationAlreadyExistsException :
|
|
53
51
|
CodedException(
|
|
@@ -4,6 +4,7 @@ import android.content.Context
|
|
|
4
4
|
import android.net.Uri
|
|
5
5
|
import android.webkit.URLUtil
|
|
6
6
|
import expo.modules.interfaces.filesystem.Permission
|
|
7
|
+
import expo.modules.kotlin.activityresult.AppContextActivityResultLauncher
|
|
7
8
|
import expo.modules.kotlin.apifeatures.EitherType
|
|
8
9
|
import expo.modules.kotlin.devtools.await
|
|
9
10
|
import expo.modules.kotlin.exception.Exceptions
|
|
@@ -30,7 +31,7 @@ class FileSystemModule : Module() {
|
|
|
30
31
|
Constants(
|
|
31
32
|
"documentDirectory" to Uri.fromFile(context.filesDir).toString() + "/",
|
|
32
33
|
"cacheDirectory" to Uri.fromFile(context.cacheDir).toString() + "/",
|
|
33
|
-
"bundleDirectory" to "asset
|
|
34
|
+
"bundleDirectory" to "asset://"
|
|
34
35
|
)
|
|
35
36
|
|
|
36
37
|
Property("totalDiskSpace") {
|
|
@@ -80,6 +81,30 @@ class FileSystemModule : Module() {
|
|
|
80
81
|
return@Coroutine destination.toURI()
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
lateinit var filePickerLauncher: AppContextActivityResultLauncher<FilePickerContractOptions, FilePickerContractResult>
|
|
85
|
+
|
|
86
|
+
RegisterActivityContracts {
|
|
87
|
+
filePickerLauncher = registerForActivityResult(
|
|
88
|
+
FilePickerContract(this@FileSystemModule)
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
AsyncFunction("pickDirectoryAsync") Coroutine { initialUri: Uri? ->
|
|
93
|
+
val result = filePickerLauncher.launch(FilePickerContractOptions(initialUri, null, PickerType.DIRECTORY))
|
|
94
|
+
when (result) {
|
|
95
|
+
is FilePickerContractResult.Success -> result.path as FileSystemDirectory
|
|
96
|
+
is FilePickerContractResult.Cancelled -> throw PickerCancelledException()
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
AsyncFunction("pickFileAsync") Coroutine { initialUri: Uri?, mimeType: String? ->
|
|
101
|
+
val result = filePickerLauncher.launch(FilePickerContractOptions(initialUri, mimeType, PickerType.FILE))
|
|
102
|
+
when (result) {
|
|
103
|
+
is FilePickerContractResult.Success -> result.path as FileSystemFile
|
|
104
|
+
is FilePickerContractResult.Cancelled -> throw PickerCancelledException()
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
83
108
|
Function("info") { url: URI ->
|
|
84
109
|
val file = File(url)
|
|
85
110
|
val permissions = appContext.filePermission?.getPathPermissions(appContext.reactContext, file.path)
|
|
@@ -3,6 +3,7 @@ package expo.modules.filesystem
|
|
|
3
3
|
import android.net.Uri
|
|
4
4
|
import android.os.Build
|
|
5
5
|
import androidx.core.net.toUri
|
|
6
|
+
import expo.modules.filesystem.unifiedfile.AssetFile
|
|
6
7
|
import expo.modules.filesystem.unifiedfile.JavaFile
|
|
7
8
|
import expo.modules.filesystem.unifiedfile.SAFDocumentFile
|
|
8
9
|
import expo.modules.filesystem.unifiedfile.UnifiedFileInterface
|
|
@@ -17,6 +18,10 @@ val Uri.isContentUri get(): Boolean {
|
|
|
17
18
|
return scheme == "content"
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
val Uri.isAssetUri get(): Boolean {
|
|
22
|
+
return scheme == "asset"
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
fun slashifyFilePath(path: String?): String? {
|
|
21
26
|
return if (path == null) {
|
|
22
27
|
null
|
|
@@ -37,6 +42,8 @@ abstract class FileSystemPath(var uri: Uri) : SharedObject() {
|
|
|
37
42
|
}
|
|
38
43
|
val newAdapter = if (uri.isContentUri) {
|
|
39
44
|
SAFDocumentFile(appContext?.reactContext ?: throw Exception("No context"), uri)
|
|
45
|
+
} else if (uri.isAssetUri) {
|
|
46
|
+
AssetFile(appContext?.reactContext ?: throw Exception("No context"), uri)
|
|
40
47
|
} else {
|
|
41
48
|
JavaFile(uri)
|
|
42
49
|
}
|
|
@@ -116,6 +123,10 @@ abstract class FileSystemPath(var uri: Uri) : SharedObject() {
|
|
|
116
123
|
// TODO: Consider adding a check for content URIs (not in legacy FS)
|
|
117
124
|
return true
|
|
118
125
|
}
|
|
126
|
+
if (uri.isAssetUri) {
|
|
127
|
+
// TODO: Consider adding a check for asset URIs – this returns asset files of Expo Go (such as root-cert), but these are already freely available on apk mirrors ect.
|
|
128
|
+
return true
|
|
129
|
+
}
|
|
119
130
|
val permissions = appContext?.filePermission?.getPathPermissions(appContext?.reactContext, javaFile.path) ?: EnumSet.noneOf(Permission::class.java)
|
|
120
131
|
return permissions.contains(permission)
|
|
121
132
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
package expo.modules.filesystem.unifiedfile
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.net.Uri
|
|
5
|
+
import android.webkit.MimeTypeMap
|
|
6
|
+
import androidx.core.net.toUri
|
|
7
|
+
import java.io.File
|
|
8
|
+
import java.io.InputStream
|
|
9
|
+
import java.io.OutputStream
|
|
10
|
+
|
|
11
|
+
class AssetFile(private val context: Context, override val uri: Uri) : UnifiedFileInterface {
|
|
12
|
+
val path: String = uri.path?.trimStart('/') ?: throw IllegalArgumentException("Invalid asset URI: $uri")
|
|
13
|
+
|
|
14
|
+
override fun exists(): Boolean = isDirectory() || isFile()
|
|
15
|
+
|
|
16
|
+
override fun isDirectory(): Boolean {
|
|
17
|
+
return context.assets.list(path)?.isNotEmpty() == true
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun isFile(): Boolean {
|
|
21
|
+
return runCatching {
|
|
22
|
+
context.assets.open(path).use { true }
|
|
23
|
+
}.getOrElse {
|
|
24
|
+
false
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override val parentFile: UnifiedFileInterface?
|
|
29
|
+
get() {
|
|
30
|
+
val currentPath = uri.path.orEmpty()
|
|
31
|
+
if (currentPath.isEmpty()) {
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
val parentPath = currentPath.substringBeforeLast('/')
|
|
36
|
+
val parentUri = "asset://$parentPath".toUri()
|
|
37
|
+
|
|
38
|
+
return AssetFile(context, parentUri)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override fun createFile(mimeType: String, displayName: String): UnifiedFileInterface? {
|
|
42
|
+
throw UnsupportedOperationException("Asset files are not writable and cannot be created")
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override fun createDirectory(displayName: String): UnifiedFileInterface? {
|
|
46
|
+
throw UnsupportedOperationException("Asset directories are not writable and cannot be created")
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
override fun delete(): Boolean = throw UnsupportedOperationException("Asset files are not writable and cannot be deleted")
|
|
50
|
+
|
|
51
|
+
override fun listFilesAsUnified(): List<UnifiedFileInterface> {
|
|
52
|
+
val list = context.assets.list(path)
|
|
53
|
+
return list?.map { name -> AssetFile(context, File(path, name).toUri()) as UnifiedFileInterface } ?: emptyList()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
override val type: String?
|
|
57
|
+
get() {
|
|
58
|
+
val extension = MimeTypeMap.getFileExtensionFromUrl(uri.toString())
|
|
59
|
+
return if (extension.isNotEmpty()) {
|
|
60
|
+
MimeTypeMap
|
|
61
|
+
.getSingleton()
|
|
62
|
+
.getMimeTypeFromExtension(extension.lowercase())
|
|
63
|
+
} else {
|
|
64
|
+
null
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
override fun lastModified(): Long? {
|
|
69
|
+
return null
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
override val fileName: String?
|
|
73
|
+
get() = uri.lastPathSegment
|
|
74
|
+
|
|
75
|
+
override val creationTime: Long? get() {
|
|
76
|
+
return null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
override fun outputStream(): OutputStream {
|
|
80
|
+
throw UnsupportedOperationException("Asset files are not writable")
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
override fun inputStream(): InputStream {
|
|
84
|
+
return context.assets.open(path)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
override fun length(): Long {
|
|
88
|
+
runCatching {
|
|
89
|
+
context.assets.openFd(path).use { assetFileDescriptor ->
|
|
90
|
+
val length = assetFileDescriptor.length
|
|
91
|
+
if (length > 0) {
|
|
92
|
+
return length
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
runCatching {
|
|
97
|
+
var size: Long = 0
|
|
98
|
+
context.assets.open(path).use { inputStream ->
|
|
99
|
+
val buffer = ByteArray(8192)
|
|
100
|
+
var read: Int
|
|
101
|
+
while (inputStream.read(buffer).also { read = it } != -1) {
|
|
102
|
+
size += read
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return size
|
|
106
|
+
}
|
|
107
|
+
return 0
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
override fun walkTopDown(): Sequence<AssetFile> = sequence {
|
|
111
|
+
yield(this@AssetFile)
|
|
112
|
+
if (isDirectory()) {
|
|
113
|
+
val assets = context.assets.list(path)
|
|
114
|
+
assets?.forEach { assetName ->
|
|
115
|
+
val childUri = "$uri/$assetName".replace("//", "/").toUri()
|
|
116
|
+
val childFile = AssetFile(context, childUri)
|
|
117
|
+
yieldAll(childFile.walkTopDown())
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -7,45 +7,56 @@ import java.io.InputStream
|
|
|
7
7
|
import java.io.OutputStream
|
|
8
8
|
|
|
9
9
|
class SAFDocumentFile(private val context: Context, override val uri: Uri) : UnifiedFileInterface {
|
|
10
|
-
private val
|
|
10
|
+
private val documentFile: DocumentFile?
|
|
11
|
+
get() {
|
|
12
|
+
// Relying on singleUri.isDirectory did not work, and there's no explicit method for this, so we check path
|
|
13
|
+
val pathSegment = uri.pathSegments.getOrNull(0) ?: "tree"
|
|
14
|
+
if (pathSegment == "document") {
|
|
15
|
+
// If the path starts with "document", we treat it as a raw file URI
|
|
16
|
+
return DocumentFile.fromSingleUri(context, uri)
|
|
17
|
+
} else {
|
|
18
|
+
// Otherwise, we treat it as a tree URI
|
|
19
|
+
return DocumentFile.fromTreeUri(context, uri)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
11
22
|
|
|
12
|
-
override fun exists(): Boolean =
|
|
23
|
+
override fun exists(): Boolean = documentFile?.exists() == true
|
|
13
24
|
|
|
14
25
|
override fun isDirectory(): Boolean {
|
|
15
|
-
return
|
|
26
|
+
return documentFile?.isDirectory == true
|
|
16
27
|
}
|
|
17
28
|
|
|
18
29
|
override fun isFile(): Boolean {
|
|
19
|
-
return
|
|
30
|
+
return documentFile?.isFile == true
|
|
20
31
|
}
|
|
21
32
|
|
|
22
33
|
override val parentFile: UnifiedFileInterface?
|
|
23
|
-
get() =
|
|
34
|
+
get() = documentFile?.parentFile?.uri?.let { SAFDocumentFile(context, it) }
|
|
24
35
|
|
|
25
36
|
override fun createFile(mimeType: String, displayName: String): UnifiedFileInterface? {
|
|
26
|
-
val documentFile =
|
|
37
|
+
val documentFile = documentFile?.createFile(mimeType, displayName)
|
|
27
38
|
return documentFile?.uri?.let { SAFDocumentFile(context, it) }
|
|
28
39
|
}
|
|
29
40
|
|
|
30
41
|
override fun createDirectory(displayName: String): UnifiedFileInterface? {
|
|
31
|
-
val documentFile =
|
|
42
|
+
val documentFile = documentFile?.createDirectory(displayName)
|
|
32
43
|
return documentFile?.uri?.let { SAFDocumentFile(context, it) }
|
|
33
44
|
}
|
|
34
45
|
|
|
35
|
-
override fun delete(): Boolean =
|
|
46
|
+
override fun delete(): Boolean = documentFile?.delete() == true
|
|
36
47
|
|
|
37
48
|
override fun listFilesAsUnified(): List<UnifiedFileInterface> =
|
|
38
|
-
|
|
49
|
+
documentFile?.listFiles()?.map { SAFDocumentFile(context, it.uri) } ?: emptyList()
|
|
39
50
|
|
|
40
51
|
override val type: String?
|
|
41
|
-
get() =
|
|
52
|
+
get() = documentFile?.type
|
|
42
53
|
|
|
43
54
|
override fun lastModified(): Long? {
|
|
44
|
-
return
|
|
55
|
+
return documentFile?.lastModified()
|
|
45
56
|
}
|
|
46
57
|
|
|
47
58
|
override val fileName: String?
|
|
48
|
-
get() =
|
|
59
|
+
get() = documentFile?.name
|
|
49
60
|
|
|
50
61
|
override val creationTime: Long? get() {
|
|
51
62
|
// It seems there's no way to get this
|
|
@@ -63,14 +74,14 @@ class SAFDocumentFile(private val context: Context, override val uri: Uri) : Uni
|
|
|
63
74
|
}
|
|
64
75
|
|
|
65
76
|
override fun length(): Long {
|
|
66
|
-
return
|
|
77
|
+
return documentFile?.length() ?: 0
|
|
67
78
|
}
|
|
68
79
|
|
|
69
80
|
override fun walkTopDown(): Sequence<SAFDocumentFile> {
|
|
70
81
|
return sequence {
|
|
71
82
|
yield(this@SAFDocumentFile)
|
|
72
83
|
if (isDirectory()) {
|
|
73
|
-
|
|
84
|
+
documentFile?.listFiles()?.forEach { child ->
|
|
74
85
|
yieldAll(SAFDocumentFile(context, child.uri).walkTopDown())
|
|
75
86
|
}
|
|
76
87
|
}
|
|
@@ -4,8 +4,13 @@ declare class ExpoFileSystemModule extends NativeModule {
|
|
|
4
4
|
FileSystemDirectory: typeof Directory;
|
|
5
5
|
FileSystemFile: typeof File;
|
|
6
6
|
downloadFileAsync(url: string, destination: File | Directory, options?: DownloadOptions): Promise<string>;
|
|
7
|
+
pickDirectoryAsync(initialUri?: string): Promise<Directory>;
|
|
8
|
+
pickFileAsync(initialUri?: string, mimeType?: string): Promise<File>;
|
|
7
9
|
totalDiskSpace: number;
|
|
8
10
|
availableDiskSpace: number;
|
|
11
|
+
documentDirectory: string;
|
|
12
|
+
cacheDirectory: string;
|
|
13
|
+
bundleDirectory: string;
|
|
9
14
|
}
|
|
10
15
|
declare const _default: ExpoFileSystemModule;
|
|
11
16
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoFileSystem.d.ts","sourceRoot":"","sources":["../src/ExpoFileSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,mBAAmB,CAAC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,OAAO,oBAAqB,SAAQ,YAAY;IACrD,mBAAmB,EAAE,OAAO,SAAS,CAAC;IACtC,cAAc,EAAE,OAAO,IAAI,CAAC;IAC5B,iBAAiB,CACf,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,IAAI,GAAG,SAAS,EAC7B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpoFileSystem.d.ts","sourceRoot":"","sources":["../src/ExpoFileSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,mBAAmB,CAAC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,OAAO,oBAAqB,SAAQ,YAAY;IACrD,mBAAmB,EAAE,OAAO,SAAS,CAAC;IACtC,cAAc,EAAE,OAAO,IAAI,CAAC;IAC5B,iBAAiB,CACf,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,IAAI,GAAG,SAAS,EAC7B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC;IAClB,kBAAkB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAC3D,aAAa,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACpE,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB;;AAED,wBAAuE"}
|
|
@@ -78,6 +78,13 @@ export declare class Directory {
|
|
|
78
78
|
* A size of the directory in bytes. Null if the directory does not exist, or it cannot be read.
|
|
79
79
|
*/
|
|
80
80
|
size: number | null;
|
|
81
|
+
/**
|
|
82
|
+
* @platform android
|
|
83
|
+
* A static method that opens a file picker to select a directory.
|
|
84
|
+
* @param initialUri An optional uri pointing to an initial folder on which the directory picker is opened.
|
|
85
|
+
* @returns a `Directory` instance. The underlying uri will be a content uri on Android.
|
|
86
|
+
*/
|
|
87
|
+
static pickDirectoryAsync(initialUri?: string): Promise<Directory>;
|
|
81
88
|
}
|
|
82
89
|
export type DownloadOptions = {
|
|
83
90
|
/**
|
|
@@ -115,7 +122,7 @@ export declare class File {
|
|
|
115
122
|
* Retrieves text from the file.
|
|
116
123
|
* @returns The contents of the file as string.
|
|
117
124
|
*/
|
|
118
|
-
textSync():
|
|
125
|
+
textSync(): string;
|
|
119
126
|
/**
|
|
120
127
|
* Retrieves content of the file as base64.
|
|
121
128
|
* @returns A promise that resolves with the contents of the file as a base64 string.
|
|
@@ -188,6 +195,14 @@ export declare class File {
|
|
|
188
195
|
* ```
|
|
189
196
|
*/
|
|
190
197
|
static downloadFileAsync(url: string, destination: Directory | File, options?: DownloadOptions): Promise<File>;
|
|
198
|
+
/**
|
|
199
|
+
* @platform android
|
|
200
|
+
* A static method that opens a file picker to select a single file of specified type.
|
|
201
|
+
* @param initialUri An optional uri pointing to an initial folder on which the file picker is opened.
|
|
202
|
+
* @param mimeType A mime type that is used to filter out files that can be picked out.
|
|
203
|
+
* @returns a `File` instance.
|
|
204
|
+
*/
|
|
205
|
+
static pickFileAsync(initialUri?: string, mimeType?: string): Promise<File>;
|
|
191
206
|
/**
|
|
192
207
|
* A size of the file in bytes. 0 if the file does not exist, or it cannot be read.
|
|
193
208
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoFileSystem.types.d.ts","sourceRoot":"","sources":["../src/ExpoFileSystem.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,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,aAAa,GAAG,IAAI;IAErC,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,GAAG,IAAI;IAEzC;;;;OAIG;IACH,aAAa,IAAI;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE;IAEvD;;OAEG;IACH,IAAI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,EAAE;IAE5B;;;;OAIG;IACH,IAAI,IAAI,aAAa;IAErB;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpoFileSystem.types.d.ts","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E,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../src/FileSystem.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAmB,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,qBAAa,KAAM,SAAQ,aAAa;IACtC;;OAEG;IACH,MAAM,KAAK,KAAK,cAEf;
|
|
1
|
+
{"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../src/FileSystem.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAmB,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,qBAAa,KAAM,SAAQ,aAAa;IACtC;;OAEG;IACH,MAAM,KAAK,KAAK,cAEf;IAED;;OAEG;IACH,MAAM,KAAK,MAAM,cAEhB;IAED;;OAEG;IACH,MAAM,KAAK,QAAQ,cAElB;IACD,MAAM,KAAK,qBAAqB,8BAS/B;IAED;;OAEG;IACH,MAAM,KAAK,cAAc,WAExB;IAED;;OAEG;IACH,MAAM,KAAK,kBAAkB,WAE5B;IAED;;OAEG;IACH,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331c89e9dc7
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c91977ae610fa808ea0765cd14182ad1d8961f59cbdf2df2396e7f77fe8cadbcd152018902a4f09474177b5ea77f78c107d6016c127d0546c4e9b0ebbf2b13fe
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
67fb8fe6d438a03c9f9b1419f17a116d
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
7f26aacfe041259700988a8f2e865b6d78a47865
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
977ef17ccaa7a6f8c09c70d2f2f2f0c1002f07df8b3756ce3905a37a7288b41b
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
36dc7ab692103570111d72588e7674ae1c7cf2c0665a351738f87dc0af98dbccb34aef221f34b5630403f2d6fd46a13cd22e4b3fb75a90f6b8b0bc2a41dd49cf
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"component": {
|
|
4
4
|
"group": "host.exp.exponent",
|
|
5
5
|
"module": "expo.modules.filesystem",
|
|
6
|
-
"version": "19.0.
|
|
6
|
+
"version": "19.0.3",
|
|
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.
|
|
79
|
-
"url": "expo.modules.filesystem-19.0.
|
|
80
|
-
"size":
|
|
81
|
-
"sha512": "
|
|
82
|
-
"sha256": "
|
|
83
|
-
"sha1": "
|
|
84
|
-
"md5": "
|
|
78
|
+
"name": "expo.modules.filesystem-19.0.3.aar",
|
|
79
|
+
"url": "expo.modules.filesystem-19.0.3.aar",
|
|
80
|
+
"size": 373316,
|
|
81
|
+
"sha512": "36dc7ab692103570111d72588e7674ae1c7cf2c0665a351738f87dc0af98dbccb34aef221f34b5630403f2d6fd46a13cd22e4b3fb75a90f6b8b0bc2a41dd49cf",
|
|
82
|
+
"sha256": "977ef17ccaa7a6f8c09c70d2f2f2f0c1002f07df8b3756ce3905a37a7288b41b",
|
|
83
|
+
"sha1": "7f26aacfe041259700988a8f2e865b6d78a47865",
|
|
84
|
+
"md5": "67fb8fe6d438a03c9f9b1419f17a116d"
|
|
85
85
|
}
|
|
86
86
|
]
|
|
87
87
|
},
|
|
@@ -153,13 +153,13 @@
|
|
|
153
153
|
],
|
|
154
154
|
"files": [
|
|
155
155
|
{
|
|
156
|
-
"name": "expo.modules.filesystem-19.0.
|
|
157
|
-
"url": "expo.modules.filesystem-19.0.
|
|
158
|
-
"size":
|
|
159
|
-
"sha512": "
|
|
160
|
-
"sha256": "
|
|
161
|
-
"sha1": "
|
|
162
|
-
"md5": "
|
|
156
|
+
"name": "expo.modules.filesystem-19.0.3.aar",
|
|
157
|
+
"url": "expo.modules.filesystem-19.0.3.aar",
|
|
158
|
+
"size": 373316,
|
|
159
|
+
"sha512": "36dc7ab692103570111d72588e7674ae1c7cf2c0665a351738f87dc0af98dbccb34aef221f34b5630403f2d6fd46a13cd22e4b3fb75a90f6b8b0bc2a41dd49cf",
|
|
160
|
+
"sha256": "977ef17ccaa7a6f8c09c70d2f2f2f0c1002f07df8b3756ce3905a37a7288b41b",
|
|
161
|
+
"sha1": "7f26aacfe041259700988a8f2e865b6d78a47865",
|
|
162
|
+
"md5": "67fb8fe6d438a03c9f9b1419f17a116d"
|
|
163
163
|
}
|
|
164
164
|
]
|
|
165
165
|
},
|
|
@@ -173,13 +173,13 @@
|
|
|
173
173
|
},
|
|
174
174
|
"files": [
|
|
175
175
|
{
|
|
176
|
-
"name": "expo.modules.filesystem-19.0.
|
|
177
|
-
"url": "expo.modules.filesystem-19.0.
|
|
178
|
-
"size":
|
|
179
|
-
"sha512": "
|
|
180
|
-
"sha256": "
|
|
181
|
-
"sha1": "
|
|
182
|
-
"md5": "
|
|
176
|
+
"name": "expo.modules.filesystem-19.0.3-sources.jar",
|
|
177
|
+
"url": "expo.modules.filesystem-19.0.3-sources.jar",
|
|
178
|
+
"size": 28421,
|
|
179
|
+
"sha512": "c91977ae610fa808ea0765cd14182ad1d8961f59cbdf2df2396e7f77fe8cadbcd152018902a4f09474177b5ea77f78c107d6016c127d0546c4e9b0ebbf2b13fe",
|
|
180
|
+
"sha256": "9cf826cfa827700e415e780bc1b4a49477ea31486d465154824b7331c89e9dc7",
|
|
181
|
+
"sha1": "5f879a11258f3b3e06b575f71e801aab8e25113b",
|
|
182
|
+
"md5": "8e4953080a31fa4851c0d3af21f5f2a8"
|
|
183
183
|
}
|
|
184
184
|
]
|
|
185
185
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
115b0114af05e17995f5bdab07a3ab16
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
733bfd800ab7ebc1d1c82e642b4edead8a901d5f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
150872c129c64983be7ab2056d944f25320d581de315845c19d76eaa1c0980f7
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
855720b3802de8a9b796433f6d8e05d5c3b456737b0f6f4f629015a5cd04667216e93f6ab85ddd074864405ef689ee5ea446463c9bef1f54d8525123e852d1e0
|
|
@@ -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.
|
|
12
|
+
<version>19.0.3</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
|
+
bd9d6af2053adec1ffb3073e8d903b4b
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
6d75988f414535c89f497db1cc5582b4c1944204
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
236607b1436c81d824e4ef0676fbabc20af5c3c4fa7fc377ae96635a450a10e8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
93c9c7905bf9a196739eefc98d7f0722ec9a2be6f237e7ac7413279b3b6e9684cc3e62d386d4490c95e1d752b37be2e911e23974f41d661564ee44226320557f
|
|
@@ -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.
|
|
7
|
-
<release>19.0.
|
|
6
|
+
<latest>19.0.3</latest>
|
|
7
|
+
<release>19.0.3</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>19.0.
|
|
9
|
+
<version>19.0.3</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20250818203955</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
bf814914808c5cde6a874f5314c5c03c
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
a6a0d0e61b39cdf7af63bdade461ea017c77ee7f
|
package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha256
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
7d7c0cb2bef2183a4840f8b5af5032596df0279a3db9935719845c5b38d16fe6
|
package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/maven-metadata.xml.sha512
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
94088dcb40367cbe08c959ce13e74789a467191884f402298b4ee4982db73bbb8138fc7bfeb9af43d37f74a8f608b357353b20a8b020a4d76064318458554c67
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-file-system",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.0.3",
|
|
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",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"preset": "expo-module-scripts"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"expo-module-scripts": "^5.0.
|
|
39
|
-
"jest-expo": "~54.0.
|
|
38
|
+
"expo-module-scripts": "^5.0.2",
|
|
39
|
+
"jest-expo": "~54.0.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"expo": "*",
|
|
43
43
|
"react-native": "*"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "475cdabd3faad56f0e8c4abcaaf21140c01c094f"
|
|
46
46
|
}
|
package/src/ExpoFileSystem.ts
CHANGED
|
@@ -10,8 +10,13 @@ declare class ExpoFileSystemModule extends NativeModule {
|
|
|
10
10
|
destination: File | Directory,
|
|
11
11
|
options?: DownloadOptions
|
|
12
12
|
): Promise<string>;
|
|
13
|
+
pickDirectoryAsync(initialUri?: string): Promise<Directory>;
|
|
14
|
+
pickFileAsync(initialUri?: string, mimeType?: string): Promise<File>;
|
|
13
15
|
totalDiskSpace: number;
|
|
14
16
|
availableDiskSpace: number;
|
|
17
|
+
documentDirectory: string;
|
|
18
|
+
cacheDirectory: string;
|
|
19
|
+
bundleDirectory: string;
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export default requireNativeModule<ExpoFileSystemModule>('FileSystem');
|
|
@@ -89,6 +89,14 @@ export declare class Directory {
|
|
|
89
89
|
* A size of the directory in bytes. Null if the directory does not exist, or it cannot be read.
|
|
90
90
|
*/
|
|
91
91
|
size: number | null;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @platform android
|
|
95
|
+
* A static method that opens a file picker to select a directory.
|
|
96
|
+
* @param initialUri An optional uri pointing to an initial folder on which the directory picker is opened.
|
|
97
|
+
* @returns a `Directory` instance. The underlying uri will be a content uri on Android.
|
|
98
|
+
*/
|
|
99
|
+
static pickDirectoryAsync(initialUri?: string): Promise<Directory>;
|
|
92
100
|
}
|
|
93
101
|
|
|
94
102
|
export type DownloadOptions = {
|
|
@@ -132,7 +140,7 @@ export declare class File {
|
|
|
132
140
|
* Retrieves text from the file.
|
|
133
141
|
* @returns The contents of the file as string.
|
|
134
142
|
*/
|
|
135
|
-
textSync():
|
|
143
|
+
textSync(): string;
|
|
136
144
|
|
|
137
145
|
/**
|
|
138
146
|
* Retrieves content of the file as base64.
|
|
@@ -223,6 +231,15 @@ export declare class File {
|
|
|
223
231
|
options?: DownloadOptions
|
|
224
232
|
): Promise<File>;
|
|
225
233
|
|
|
234
|
+
/**
|
|
235
|
+
* @platform android
|
|
236
|
+
* A static method that opens a file picker to select a single file of specified type.
|
|
237
|
+
* @param initialUri An optional uri pointing to an initial folder on which the file picker is opened.
|
|
238
|
+
* @param mimeType A mime type that is used to filter out files that can be picked out.
|
|
239
|
+
* @returns a `File` instance.
|
|
240
|
+
*/
|
|
241
|
+
static pickFileAsync(initialUri?: string, mimeType?: string): Promise<File>;
|
|
242
|
+
|
|
226
243
|
/**
|
|
227
244
|
* A size of the file in bytes. 0 if the file does not exist, or it cannot be read.
|
|
228
245
|
*/
|
package/src/FileSystem.ts
CHANGED
|
@@ -10,6 +10,7 @@ export class Paths extends PathUtilities {
|
|
|
10
10
|
static get cache() {
|
|
11
11
|
return new Directory(ExpoFileSystem.cacheDirectory);
|
|
12
12
|
}
|
|
13
|
+
|
|
13
14
|
/**
|
|
14
15
|
* A property containing the bundle directory – the directory where assets bundled with the application are stored.
|
|
15
16
|
*/
|
|
@@ -124,6 +125,11 @@ File.downloadFileAsync = async function downloadFileAsync(
|
|
|
124
125
|
return new File(outputURI);
|
|
125
126
|
};
|
|
126
127
|
|
|
128
|
+
File.pickFileAsync = async function (initialUri?: string, mimeType?: string) {
|
|
129
|
+
const file = (await ExpoFileSystem.pickFileAsync(initialUri, mimeType)).uri;
|
|
130
|
+
return new File(file);
|
|
131
|
+
};
|
|
132
|
+
|
|
127
133
|
/**
|
|
128
134
|
* Represents a directory on the filesystem.
|
|
129
135
|
*
|
|
@@ -178,3 +184,8 @@ export class Directory extends ExpoFileSystem.FileSystemDirectory {
|
|
|
178
184
|
return new Directory(super.createDirectory(name).uri);
|
|
179
185
|
}
|
|
180
186
|
}
|
|
187
|
+
|
|
188
|
+
Directory.pickDirectoryAsync = async function (initialUri?: string) {
|
|
189
|
+
const directory = (await ExpoFileSystem.pickDirectoryAsync(initialUri)).uri;
|
|
190
|
+
return new Directory(directory);
|
|
191
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1b671bd915b3a01d585d676367ddf508
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
e2c5155a0d5312646eaabf1932df414ebe996bdf
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
8fb9d4425d07c85743203381f588a6e3f7310078986d26bdd4553b7eed770d89
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3a192ba23bc4b2423142c3aae16cc8014ff5e1f9a29d1f0d7c8ce2fca93418b45b974272071cc4091da2485b8a037a7459c1dc5fc0ab29892e1ce92682368930
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
b1651ae06af2d05498af6f6ba2eb1ca8
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
68fa94eb248341effd8afe92bee7335ec2df9c01
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
a83e3d54e55fb18bd393412ab7f85aacf27246eadd5f137f9d8c4c5f98e13630
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
65ea717a289b2788e5ad9143eaa05e625b2135b9a9e08e900928caee25e356c42773b639687aa07fc0ae996c85a74605aea7acf7dd7d31ed304694312724d118
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
195c279c5b3c4a13857650587d4326dd
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
b517a527fcccbac5d9abed57d8e836b66e62cf7e
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
a362f09e2f97192a1de20786ef91ec5046ade2a6efdb9327b66f4d02ae25673f
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
10795b45afd43b375e68c129e8d558397b473abed07b89c11da2a961970d1c1fa3c96e362eda4e9f00b6fa339406c40f85e8736322b0bace838c4094b0ed0de9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
d7077baf27cc3fcb7e3e449f53746d7c
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
66d69ffb3bd0f202dd710edbb56e605b2d1bde0d
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
7307f9f95088cead485919da171b0b855e5db2365c4aedf1db0e66221f76d454
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ded938ebd869a254178235b669d2d047d82cae8af4384dba8326b51ead203ce090545d45d08b69cb58e25d9b05616987a2e109f95d2e18be3022d69ef944c471
|