expo-file-system 13.0.3 → 13.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,16 +10,11 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
- ## 13.0.3 — 2021-10-21
13
+ ## 13.1.0 — 2021-11-17
14
14
 
15
15
  ### 🐛 Bug fixes
16
16
 
17
17
  - Fixed `uploadAsync` failing to resolve when using `BINARY_CONTENT`. ([#14764](https://github.com/expo/expo/pull/14764) by [@cruzach](https://github.com/cruzach))
18
-
19
- ## 13.0.2 — 2021-10-15
20
-
21
- ### 🐛 Bug fixes
22
-
23
18
  - Fix `okio` library build error for `react-native@0.65` or above. ([#14761](https://github.com/expo/expo/pull/14761) by [@kudo](https://github.com/kudo))
24
19
 
25
20
  ## 13.0.1 — 2021-10-01
@@ -40,6 +35,7 @@ _This version does not introduce any user-facing changes._
40
35
  ### 💡 Others
41
36
 
42
37
  - Updated `@expo/config-plugins` ([#14443](https://github.com/expo/expo/pull/14443) by [@EvanBacon](https://github.com/EvanBacon))
38
+ - Rewritten module to Kotlin. ([#14549](https://github.com/expo/expo/pull/14549) by [@mstach60161](https://github.com/mstach60161))
43
39
 
44
40
  ## 12.0.0 — 2021-09-08
45
41
 
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '13.0.3'
6
+ version = '13.1.0'
7
7
 
8
8
  buildscript {
9
9
  // Simple helper that allows the root project to override versions declared by this library.
@@ -53,11 +53,15 @@ android {
53
53
  targetCompatibility JavaVersion.VERSION_1_8
54
54
  }
55
55
 
56
+ kotlinOptions {
57
+ jvmTarget = JavaVersion.VERSION_1_8
58
+ }
59
+
56
60
  defaultConfig {
57
61
  minSdkVersion safeExtGet("minSdkVersion", 21)
58
62
  targetSdkVersion safeExtGet("targetSdkVersion", 30)
59
63
  versionCode 30
60
- versionName "13.0.3"
64
+ versionName "13.1.0"
61
65
  }
62
66
  lintOptions {
63
67
  abortOnError false
@@ -9,7 +9,7 @@ import okio.Sink
9
9
  import java.io.IOException
10
10
 
11
11
  @FunctionalInterface
12
- interface RequestBodyDecorator {
12
+ fun interface RequestBodyDecorator {
13
13
  fun decorate(requestBody: RequestBody): RequestBody
14
14
  }
15
15
 
@@ -0,0 +1,48 @@
1
+ package expo.modules.filesystem
2
+
3
+ import android.content.Context
4
+ import expo.modules.interfaces.filesystem.FilePermissionModuleInterface
5
+ import expo.modules.core.interfaces.InternalModule
6
+ import expo.modules.interfaces.filesystem.Permission
7
+ import java.io.File
8
+ import java.io.IOException
9
+ import java.util.*
10
+
11
+ // The class needs to be 'open', because it's inherited in expoview
12
+ open class FilePermissionModule : FilePermissionModuleInterface, InternalModule {
13
+ override fun getExportedInterfaces(): List<Class<*>> =
14
+ listOf(FilePermissionModuleInterface::class.java)
15
+
16
+ override fun getPathPermissions(context: Context, path: String): EnumSet<Permission> =
17
+ getInternalPathPermissions(path, context) ?: getExternalPathPermissions(path)
18
+
19
+ private fun getInternalPathPermissions(path: String, context: Context): EnumSet<Permission>? {
20
+ return try {
21
+ val canonicalPath = File(path).canonicalPath
22
+ getInternalPaths(context)
23
+ .firstOrNull { dir -> canonicalPath.startsWith("$dir/") || dir == canonicalPath }
24
+ ?.let { EnumSet.of(Permission.READ, Permission.WRITE) }
25
+ } catch (e: IOException) {
26
+ EnumSet.noneOf(Permission::class.java)
27
+ }
28
+ }
29
+
30
+ protected open fun getExternalPathPermissions(path: String): EnumSet<Permission> {
31
+ val file = File(path)
32
+ return EnumSet.noneOf(Permission::class.java).apply {
33
+ if (file.canRead()) {
34
+ add(Permission.READ)
35
+ }
36
+ if (file.canWrite()) {
37
+ add(Permission.WRITE)
38
+ }
39
+ }
40
+ }
41
+
42
+ @Throws(IOException::class)
43
+ private fun getInternalPaths(context: Context): List<String> =
44
+ listOf(
45
+ context.filesDir.canonicalPath,
46
+ context.cacheDir.canonicalPath
47
+ )
48
+ }
@@ -0,0 +1,5 @@
1
+ package expo.modules.filesystem
2
+
3
+ import androidx.core.content.FileProvider
4
+
5
+ class FileSystemFileProvider : FileProvider()