expo-document-picker 13.1.6-canary-20250613-b29d676 → 14.0.0-canary-20250630-547cd82

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 +10 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/documentpicker/DocumentDetailsReader.kt +29 -4
  4. package/android/src/main/java/expo/modules/documentpicker/DocumentPickerExceptions.kt +0 -3
  5. package/android/src/main/java/expo/modules/documentpicker/DocumentPickerModule.kt +10 -18
  6. package/android/src/main/java/expo/modules/documentpicker/DocumentPickerResults.kt +4 -1
  7. package/build/ExpoDocumentPicker.web.js +5 -4
  8. package/build/ExpoDocumentPicker.web.js.map +1 -1
  9. package/build/types.d.ts +12 -2
  10. package/build/types.d.ts.map +1 -1
  11. package/build/types.js.map +1 -1
  12. package/expo-module.config.json +1 -1
  13. package/ios/DocumentPickerModule.swift +13 -6
  14. package/ios/DocumentPickerResponse.swift +6 -0
  15. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82-sources.jar +0 -0
  16. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82-sources.jar.md5 +1 -0
  17. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82-sources.jar.sha1 +1 -0
  18. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82-sources.jar.sha256 +1 -0
  19. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82-sources.jar.sha512 +1 -0
  20. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.aar +0 -0
  21. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.aar.md5 +1 -0
  22. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.aar.sha1 +1 -0
  23. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.aar.sha256 +1 -0
  24. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.aar.sha512 +1 -0
  25. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/{13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.module → 14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.module} +22 -22
  26. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.module.md5 +1 -0
  27. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.module.sha1 +1 -0
  28. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.module.sha256 +1 -0
  29. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.module.sha512 +1 -0
  30. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/{13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.pom → 14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.pom} +1 -1
  31. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.pom.md5 +1 -0
  32. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.pom.sha1 +1 -0
  33. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.pom.sha256 +1 -0
  34. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/14.0.0-canary-20250630-547cd82/expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.pom.sha512 +1 -0
  35. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/maven-metadata.xml +4 -4
  36. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/maven-metadata.xml.md5 +1 -1
  37. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/maven-metadata.xml.sha1 +1 -1
  38. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/maven-metadata.xml.sha256 +1 -1
  39. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/maven-metadata.xml.sha512 +1 -1
  40. package/package.json +3 -3
  41. package/src/ExpoDocumentPicker.web.ts +5 -4
  42. package/src/types.ts +12 -2
  43. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676-sources.jar +0 -0
  44. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676-sources.jar.md5 +0 -1
  45. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676-sources.jar.sha1 +0 -1
  46. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676-sources.jar.sha256 +0 -1
  47. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676-sources.jar.sha512 +0 -1
  48. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.aar +0 -0
  49. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.aar.md5 +0 -1
  50. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.aar.sha1 +0 -1
  51. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.aar.sha256 +0 -1
  52. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.aar.sha512 +0 -1
  53. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.module.md5 +0 -1
  54. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.module.sha1 +0 -1
  55. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.module.sha256 +0 -1
  56. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.module.sha512 +0 -1
  57. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.pom.md5 +0 -1
  58. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.pom.sha1 +0 -1
  59. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.pom.sha256 +0 -1
  60. package/local-maven-repo/host/exp/exponent/expo.modules.documentpicker/13.1.6-canary-20250613-b29d676/expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.pom.sha512 +0 -1
package/CHANGELOG.md CHANGED
@@ -4,12 +4,22 @@
4
4
 
5
5
  ### 🛠 Breaking changes
6
6
 
7
+ - [Web] getDocumentAsync() no longer returns base64 by default. The uri on web now always points to a Blob created via URL.createObjectURL(), which can be used for previews or appended to FormData for uploads. Selecting large files on web is now almost instant, since there’s no base64 conversion by default. If you still need base64, you can pass base64: true in the options. A new base64 field will then be included in the result. ([#37443](https://github.com/expo/expo/pull/37443) by [@hirbod](https://github.com/hirbod))
8
+
7
9
  ### 🎉 New features
8
10
 
11
+ - [iOS][Android] add lastModified for iOS and Android to align with web ([#37429](https://github.com/expo/expo/pull/37429) by [@hirbod](https://github.com/hirbod))
12
+
9
13
  ### 🐛 Bug fixes
10
14
 
11
15
  ### 💡 Others
12
16
 
17
+ ## 13.1.6 - 2025-06-18
18
+
19
+ ### 🐛 Bug fixes
20
+
21
+ - [Android] avoid hard crash in case of an exception ([#37110](https://github.com/expo/expo/pull/37110) by [@vonovak](https://github.com/vonovak))
22
+
13
23
  ## 13.1.5 — 2025-04-30
14
24
 
15
25
  _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 = "13.1.6-canary-20250613-b29d676"
7
+ version = "14.0.0-canary-20250630-547cd82"
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.documentpicker"
11
11
  defaultConfig {
12
12
  versionCode 17
13
- versionName '13.1.6-canary-20250613-b29d676'
13
+ versionName '14.0.0-canary-20250630-547cd82'
14
14
  }
15
15
  }
16
16
 
@@ -3,9 +3,12 @@ package expo.modules.documentpicker
3
3
  import android.content.Context
4
4
  import android.net.Uri
5
5
  import android.provider.OpenableColumns
6
+ import android.provider.DocumentsContract
7
+ import java.io.File
8
+ import java.io.IOException
6
9
 
7
10
  class DocumentDetailsReader(private val context: Context) {
8
- fun read(uri: Uri): DocumentInfo? {
11
+ fun read(uri: Uri): DocumentInfo {
9
12
  context
10
13
  .contentResolver
11
14
  .query(uri, null, null, null, null)
@@ -21,8 +24,30 @@ class DocumentDetailsReader(private val context: Context) {
21
24
  }
22
25
  }
23
26
  val mimeType = context.contentResolver.getType(uri)
24
- return DocumentInfo(uri, name, mimeType, size)
25
- }
26
- return null
27
+
28
+ // Get last modified date or use current date if not available.
29
+ // This follows the Web API spec.
30
+ // https://developer.mozilla.org/en-US/docs/Web/API/File/lastModified
31
+ val lastModified = try {
32
+ // First try to get it from the content resolver
33
+ val lastModifiedColumn = cursor.getColumnIndex(DocumentsContract.Document.COLUMN_LAST_MODIFIED)
34
+ if (lastModifiedColumn != -1 && !cursor.isNull(lastModifiedColumn)) {
35
+ cursor.getLong(lastModifiedColumn)
36
+ } else {
37
+ // Fallback to getting it from the file
38
+ val file = File(uri.path ?: "")
39
+ if (file.exists()) {
40
+ file.lastModified()
41
+ } else {
42
+ System.currentTimeMillis()
43
+ }
44
+ }
45
+ } catch (e: Exception) {
46
+ // If all else fails, use current time
47
+ System.currentTimeMillis()
48
+ }
49
+
50
+ return DocumentInfo(uri, name, mimeType, size, lastModified)
51
+ } ?: throw IOException("Failed to read document details for URI: $uri")
27
52
  }
28
53
  }
@@ -5,8 +5,5 @@ import expo.modules.kotlin.exception.CodedException
5
5
  class PickingInProgressException :
6
6
  CodedException("Different document picking in progress. Await other document picking first.")
7
7
 
8
- class FailedToCopyToCacheException :
9
- CodedException("Failed to copy to cache directory.")
10
-
11
8
  class FailedToReadDocumentException :
12
9
  CodedException("Failed to read the selected document.")
@@ -6,15 +6,14 @@ import android.content.Intent
6
6
  import android.net.Uri
7
7
  import expo.modules.core.utilities.FileUtilities
8
8
  import expo.modules.kotlin.Promise
9
- import expo.modules.kotlin.exception.CodedException
10
9
  import expo.modules.kotlin.exception.Exceptions
10
+ import expo.modules.kotlin.exception.toCodedException
11
11
  import expo.modules.kotlin.modules.Module
12
12
  import expo.modules.kotlin.modules.ModuleDefinition
13
13
  import org.apache.commons.io.FilenameUtils
14
14
  import org.apache.commons.io.IOUtils
15
15
  import java.io.File
16
16
  import java.io.FileOutputStream
17
- import java.io.IOException
18
17
 
19
18
  private const val OPEN_DOCUMENT_CODE = 4137
20
19
 
@@ -60,8 +59,8 @@ class DocumentPickerModule : Module() {
60
59
  } else {
61
60
  handleSingleSelection(intent)
62
61
  }
63
- } catch (e: CodedException) {
64
- promise.resolve(e)
62
+ } catch (e: Exception) {
63
+ promise.reject(e.toCodedException())
65
64
  }
66
65
  } else {
67
66
  promise.resolve(
@@ -73,22 +72,17 @@ class DocumentPickerModule : Module() {
73
72
  }
74
73
  }
75
74
 
76
- private fun copyDocumentToCacheDirectory(documentUri: Uri, name: String): Uri? {
75
+ private fun copyDocumentToCacheDirectory(documentUri: Uri, name: String): Uri {
77
76
  val outputFilePath = FileUtilities.generateOutputPath(
78
77
  context.cacheDir,
79
78
  "DocumentPicker",
80
79
  FilenameUtils.getExtension(name)
81
80
  )
82
81
  val outputFile = File(outputFilePath)
83
- try {
84
- context.contentResolver.openInputStream(documentUri).use { inputStream ->
85
- FileOutputStream(outputFile).use { outputStream ->
86
- IOUtils.copy(inputStream, outputStream)
87
- }
82
+ context.contentResolver.openInputStream(documentUri).use { inputStream ->
83
+ FileOutputStream(outputFile).use { outputStream ->
84
+ IOUtils.copy(inputStream, outputStream)
88
85
  }
89
- } catch (e: IOException) {
90
- e.printStackTrace()
91
- return null
92
86
  }
93
87
  return Uri.fromFile(outputFile)
94
88
  }
@@ -120,15 +114,13 @@ class DocumentPickerModule : Module() {
120
114
  private fun readDocumentDetails(uri: Uri): DocumentInfo {
121
115
  val originalDocumentDetails = DocumentDetailsReader(context).read(uri)
122
116
 
123
- val details = if (!copyToCacheDirectory || originalDocumentDetails == null) {
117
+ val details = if (!copyToCacheDirectory) {
124
118
  originalDocumentDetails
125
119
  } else {
126
120
  val copyPath = copyDocumentToCacheDirectory(uri, originalDocumentDetails.name)
127
- copyPath?.let {
128
- originalDocumentDetails.copy(uri = it)
129
- } ?: throw FailedToCopyToCacheException()
121
+ originalDocumentDetails.copy(uri = copyPath)
130
122
  }
131
123
 
132
- return details ?: throw FailedToReadDocumentException()
124
+ return details
133
125
  }
134
126
  }
@@ -23,5 +23,8 @@ data class DocumentInfo(
23
23
  val mimeType: String?,
24
24
 
25
25
  @Field
26
- val size: Long?
26
+ val size: Long?,
27
+
28
+ @Field
29
+ val lastModified: Long
27
30
  ) : Record
@@ -1,6 +1,6 @@
1
1
  import { Platform } from 'expo-modules-core';
2
2
  export default {
3
- async getDocumentAsync({ type = '*/*', multiple = false, base64 = true, }) {
3
+ async getDocumentAsync({ type = '*/*', multiple = false, base64 = false, }) {
4
4
  // SSR guard
5
5
  if (!Platform.isDOMAvailable) {
6
6
  return { canceled: true, assets: null };
@@ -47,7 +47,7 @@ function readFileAsync(targetFile, base64 = true) {
47
47
  const mimeType = targetFile.type;
48
48
  if (!base64) {
49
49
  resolve({
50
- uri: targetFile.webkitRelativePath,
50
+ uri: URL.createObjectURL(targetFile),
51
51
  mimeType,
52
52
  name: targetFile.name,
53
53
  lastModified: targetFile.lastModified,
@@ -61,9 +61,10 @@ function readFileAsync(targetFile, base64 = true) {
61
61
  reject(new Error(`Failed to read the selected media because the operation failed.`));
62
62
  };
63
63
  reader.onload = ({ target }) => {
64
- const uri = target.result;
64
+ const base64 = target.result;
65
65
  resolve({
66
- uri,
66
+ uri: URL.createObjectURL(targetFile),
67
+ base64,
67
68
  mimeType,
68
69
  name: targetFile.name,
69
70
  lastModified: targetFile.lastModified,
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoDocumentPicker.web.js","sourceRoot":"","sources":["../src/ExpoDocumentPicker.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,eAAe;IACb,KAAK,CAAC,gBAAgB,CAAC,EACrB,IAAI,GAAG,KAAK,EACZ,QAAQ,GAAG,KAAK,EAChB,MAAM,GAAG,IAAI,GACS;QACtB,YAAY;QACZ,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;YAC7B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAC1C,CAAC;QAED,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QAC7B,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACnC,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC1E,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAChD,IAAI,QAAQ,EAAE,CAAC;YACb,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAC7C,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,WAAW,CAA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Aa,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,SAAS,aAAa,CAAC,UAAgB,EAAE,SAAkB,IAAI;IAC7D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC;QACjC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,CAAC;gBACN,GAAG,EAAE,UAAU,CAAC,kBAAkB;gBAClC,QAAQ;gBACR,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,YAAY,EAAE,UAAU,CAAC,YAAY;gBACrC,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,IAAI,EAAE,UAAU;aACjB,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE;YACpB,MAAM,CAAC,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC,CAAC;QACvF,CAAC,CAAC;QACF,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YAC7B,MAAM,GAAG,GAAI,MAAc,CAAC,MAAM,CAAC;YACnC,OAAO,CAAC;gBACN,GAAG;gBACH,QAAQ;gBACR,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,YAAY,EAAE,UAAU,CAAC,YAAY;gBACrC,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,IAAI,EAAE,UAAU;aACjB,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,6CAA6C;QAC7C,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Platform } from 'expo-modules-core';\n\nimport { DocumentPickerAsset, DocumentPickerOptions, DocumentPickerResult } from './types';\n\nexport default {\n async getDocumentAsync({\n type = '*/*',\n multiple = false,\n base64 = true,\n }: DocumentPickerOptions): Promise<DocumentPickerResult> {\n // SSR guard\n if (!Platform.isDOMAvailable) {\n return { canceled: true, assets: null };\n }\n\n const input = document.createElement('input');\n input.style.display = 'none';\n input.setAttribute('type', 'file');\n input.setAttribute('accept', Array.isArray(type) ? type.join(',') : type);\n input.setAttribute('id', String(Math.random()));\n if (multiple) {\n input.setAttribute('multiple', 'multiple');\n }\n\n document.body.appendChild(input);\n\n return new Promise((resolve, reject) => {\n input.addEventListener('change', async () => {\n if (input.files) {\n const results: Promise<DocumentPickerAsset>[] = [];\n for (let i = 0; i < input.files.length; i++) {\n results.push(readFileAsync(input.files[i], base64));\n }\n try {\n const assets = await Promise.all(results);\n resolve({ canceled: false, assets, output: input.files });\n } catch (e) {\n reject(e);\n }\n } else {\n resolve({ canceled: true, assets: null });\n }\n\n document.body.removeChild(input);\n });\n\n input.addEventListener('cancel', () => {\n resolve({ canceled: true, assets: null });\n });\n\n const event = new MouseEvent('click');\n input.dispatchEvent(event);\n });\n },\n};\n\nfunction readFileAsync(targetFile: File, base64: boolean = true): Promise<DocumentPickerAsset> {\n return new Promise((resolve, reject) => {\n const mimeType = targetFile.type;\n if (!base64) {\n resolve({\n uri: targetFile.webkitRelativePath,\n mimeType,\n name: targetFile.name,\n lastModified: targetFile.lastModified,\n size: targetFile.size,\n file: targetFile,\n });\n return;\n }\n const reader = new FileReader();\n reader.onerror = () => {\n reject(new Error(`Failed to read the selected media because the operation failed.`));\n };\n reader.onload = ({ target }) => {\n const uri = (target as any).result;\n resolve({\n uri,\n mimeType,\n name: targetFile.name,\n lastModified: targetFile.lastModified,\n size: targetFile.size,\n file: targetFile,\n });\n };\n\n // Read in the image file as a binary string.\n reader.readAsDataURL(targetFile);\n });\n}\n"]}
1
+ {"version":3,"file":"ExpoDocumentPicker.web.js","sourceRoot":"","sources":["../src/ExpoDocumentPicker.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM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gBACpC,QAAQ;gBACR,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,YAAY,EAAE,UAAU,CAAC,YAAY;gBACrC,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,IAAI,EAAE,UAAU;aACjB,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE;YACpB,MAAM,CAAC,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC,CAAC;QACvF,CAAC,CAAC;QACF,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YAC7B,MAAM,MAAM,GAAI,MAAc,CAAC,MAAM,CAAC;YACtC,OAAO,CAAC;gBACN,GAAG,EAAE,GAAG,CAAC,eAAe,CAAC,UAAU,CAAC;gBACpC,MAAM;gBACN,QAAQ;gBACR,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,YAAY,EAAE,UAAU,CAAC,YAAY;gBACrC,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,IAAI,EAAE,UAAU;aACjB,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,6CAA6C;QAC7C,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Platform } from 'expo-modules-core';\n\nimport { DocumentPickerAsset, DocumentPickerOptions, DocumentPickerResult } from './types';\n\nexport default {\n async getDocumentAsync({\n type = '*/*',\n multiple = false,\n base64 = false,\n }: DocumentPickerOptions): Promise<DocumentPickerResult> {\n // SSR guard\n if (!Platform.isDOMAvailable) {\n return { canceled: true, assets: null };\n }\n\n const input = document.createElement('input');\n input.style.display = 'none';\n input.setAttribute('type', 'file');\n input.setAttribute('accept', Array.isArray(type) ? type.join(',') : type);\n input.setAttribute('id', String(Math.random()));\n if (multiple) {\n input.setAttribute('multiple', 'multiple');\n }\n\n document.body.appendChild(input);\n\n return new Promise((resolve, reject) => {\n input.addEventListener('change', async () => {\n if (input.files) {\n const results: Promise<DocumentPickerAsset>[] = [];\n for (let i = 0; i < input.files.length; i++) {\n results.push(readFileAsync(input.files[i], base64));\n }\n try {\n const assets = await Promise.all(results);\n resolve({ canceled: false, assets, output: input.files });\n } catch (e) {\n reject(e);\n }\n } else {\n resolve({ canceled: true, assets: null });\n }\n\n document.body.removeChild(input);\n });\n\n input.addEventListener('cancel', () => {\n resolve({ canceled: true, assets: null });\n });\n\n const event = new MouseEvent('click');\n input.dispatchEvent(event);\n });\n },\n};\n\nfunction readFileAsync(targetFile: File, base64: boolean = true): Promise<DocumentPickerAsset> {\n return new Promise((resolve, reject) => {\n const mimeType = targetFile.type;\n if (!base64) {\n resolve({\n uri: URL.createObjectURL(targetFile),\n mimeType,\n name: targetFile.name,\n lastModified: targetFile.lastModified,\n size: targetFile.size,\n file: targetFile,\n });\n return;\n }\n const reader = new FileReader();\n reader.onerror = () => {\n reject(new Error(`Failed to read the selected media because the operation failed.`));\n };\n reader.onload = ({ target }) => {\n const base64 = (target as any).result;\n resolve({\n uri: URL.createObjectURL(targetFile),\n base64,\n mimeType,\n name: targetFile.name,\n lastModified: targetFile.lastModified,\n size: targetFile.size,\n file: targetFile,\n });\n };\n\n // Read in the image file as a binary string.\n reader.readAsDataURL(targetFile);\n });\n}\n"]}
package/build/types.d.ts CHANGED
@@ -11,6 +11,8 @@ export type DocumentPickerOptions = {
11
11
  * which allows other Expo APIs to read the file immediately. This may impact performance for
12
12
  * large files, so you should consider setting this to `false` if you expect users to pick
13
13
  * particularly large files and your app does not need immediate read access.
14
+ * @platform ios
15
+ * @platform android
14
16
  * @default true
15
17
  */
16
18
  copyToCacheDirectory?: boolean;
@@ -46,14 +48,22 @@ export type DocumentPickerAsset = {
46
48
  */
47
49
  mimeType?: string;
48
50
  /**
49
- * Timestamp of last document modification.
51
+ * Timestamp of last document modification. [Web API specs](https://developer.mozilla.org/en-US/docs/Web/API/File/lastModified)
52
+ * The lastModified provides the last modified date of the file as the number
53
+ * of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files
54
+ * without a known last modified date return the current date.
50
55
  */
51
- lastModified?: number;
56
+ lastModified: number;
52
57
  /**
53
58
  * `File` object for the parity with web File API.
54
59
  * @platform web
55
60
  */
56
61
  file?: File;
62
+ /**
63
+ * Base64 string of the file.
64
+ * @platform web
65
+ */
66
+ base64?: string;
57
67
  };
58
68
  /**
59
69
  * Type representing successful and canceled document pick result.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,2BAA2B,GAAG,4BAA4B,CAAC;AAE9F;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC;IAChB;;OAEG;IACH,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B;;;OAGG;IACH,MAAM,CAAC,E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AM,4BAA4B,GAAG;IACzC;;OAEG;IACH,QAAQ,EAAE,IAAI,CAAC;IACf;;OAEG;IACH,MAAM,EAAE,IAAI,CAAC;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC;CACf,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["// @needsAudit\nexport type DocumentPickerOptions = {\n /**\n * The [MIME type(s)](https://en.wikipedia.org/wiki/Media_type) of the documents that are available\n * to be picked. It also supports wildcards like `'image/*'` to choose any image. To allow any type\n * of document you can use `'&ast;/*'`.\n * @default '&ast;/*'\n */\n type?: string | string[];\n /**\n * If `true`, the picked file is copied to [`FileSystem.CacheDirectory`](./filesystem#filesystemcachedirectory),\n * which allows other Expo APIs to read the file immediately. This may impact performance for\n * large files, so you should consider setting this to `false` if you expect users to pick\n * particularly large files and your app does not need immediate read access.\n * @default true\n */\n copyToCacheDirectory?: boolean;\n /**\n * Allows multiple files to be selected from the system UI.\n * @default false\n *\n */\n multiple?: boolean;\n /**\n * If `true`, asset url is base64 from the file\n * If `false`, asset url is the file url parameter\n * @platform web\n * @default true\n */\n base64?: boolean;\n};\n\nexport type DocumentPickerAsset = {\n /**\n * Document original name.\n */\n name: string;\n /**\n * Document size in bytes.\n */\n size?: number;\n /**\n * An URI to the local document file.\n */\n uri: string;\n /**\n * Document MIME type.\n */\n mimeType?: string;\n /**\n * Timestamp of last document modification.\n */\n lastModified?: number;\n /**\n * `File` object for the parity with web File API.\n * @platform web\n */\n file?: File;\n};\n\n/**\n * Type representing successful and canceled document pick result.\n */\nexport type DocumentPickerResult = DocumentPickerSuccessResult | DocumentPickerCanceledResult;\n\n/**\n * Type representing successful pick result.\n */\nexport type DocumentPickerSuccessResult = {\n /**\n * If asset data have been returned this should always be `false`.\n */\n canceled: false;\n /**\n * An array of picked assets.\n */\n assets: DocumentPickerAsset[];\n /**\n * `FileList` object for the parity with web File API.\n * @platform web\n */\n output?: FileList;\n};\n\n/**\n * Type representing canceled pick result.\n */\nexport type DocumentPickerCanceledResult = {\n /**\n * Always `true` when the request was canceled.\n */\n canceled: true;\n /**\n * Always `null` when the request was canceled.\n */\n assets: null;\n /**\n * Always `null` when the request was canceled.\n * @platform web\n */\n output?: null;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["// @needsAudit\nexport type DocumentPickerOptions = {\n /**\n * The [MIME type(s)](https://en.wikipedia.org/wiki/Media_type) of the documents that are available\n * to be picked. It also supports wildcards like `'image/*'` to choose any image. To allow any type\n * of document you can use `'&ast;/*'`.\n * @default '&ast;/*'\n */\n type?: string | string[];\n /**\n * If `true`, the picked file is copied to [`FileSystem.CacheDirectory`](./filesystem#filesystemcachedirectory),\n * which allows other Expo APIs to read the file immediately. This may impact performance for\n * large files, so you should consider setting this to `false` if you expect users to pick\n * particularly large files and your app does not need immediate read access.\n * @platform ios\n * @platform android\n * @default true\n */\n copyToCacheDirectory?: boolean;\n /**\n * Allows multiple files to be selected from the system UI.\n * @default false\n *\n */\n multiple?: boolean;\n /**\n * If `true`, asset url is base64 from the file\n * If `false`, asset url is the file url parameter\n * @platform web\n * @default true\n */\n base64?: boolean;\n};\n\nexport type DocumentPickerAsset = {\n /**\n * Document original name.\n */\n name: string;\n /**\n * Document size in bytes.\n */\n size?: number;\n /**\n * An URI to the local document file.\n */\n uri: string;\n /**\n * Document MIME type.\n */\n mimeType?: string;\n /**\n * Timestamp of last document modification. [Web API specs](https://developer.mozilla.org/en-US/docs/Web/API/File/lastModified)\n * The lastModified provides the last modified date of the file as the number\n * of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files\n * without a known last modified date return the current date.\n */\n lastModified: number;\n /**\n * `File` object for the parity with web File API.\n * @platform web\n */\n file?: File;\n /**\n * Base64 string of the file.\n * @platform web\n */\n base64?: string;\n};\n\n/**\n * Type representing successful and canceled document pick result.\n */\nexport type DocumentPickerResult = DocumentPickerSuccessResult | DocumentPickerCanceledResult;\n\n/**\n * Type representing successful pick result.\n */\nexport type DocumentPickerSuccessResult = {\n /**\n * If asset data have been returned this should always be `false`.\n */\n canceled: false;\n /**\n * An array of picked assets.\n */\n assets: DocumentPickerAsset[];\n /**\n * `FileList` object for the parity with web File API.\n * @platform web\n */\n output?: FileList;\n};\n\n/**\n * Type representing canceled pick result.\n */\nexport type DocumentPickerCanceledResult = {\n /**\n * Always `true` when the request was canceled.\n */\n canceled: true;\n /**\n * Always `null` when the request was canceled.\n */\n assets: null;\n /**\n * Always `null` when the request was canceled.\n * @platform web\n */\n output?: null;\n};\n"]}
@@ -8,7 +8,7 @@
8
8
  "publication": {
9
9
  "groupId": "host.exp.exponent",
10
10
  "artifactId": "expo.modules.documentpicker",
11
- "version": "13.1.6-canary-20250613-b29d676",
11
+ "version": "14.0.0-canary-20250630-547cd82",
12
12
  "repository": "local-maven-repo"
13
13
  }
14
14
  }
@@ -1,6 +1,6 @@
1
1
  import ExpoModulesCore
2
- import UIKit
3
2
  import MobileCoreServices
3
+ import UIKit
4
4
 
5
5
  struct PickingContext {
6
6
  let promise: Promise
@@ -49,7 +49,7 @@ public class DocumentPickerModule: Module, PickingResultHandler {
49
49
 
50
50
  func didPickDocumentsAt(urls: [URL]) {
51
51
  guard let options = self.pickingContext?.options,
52
- let promise = self.pickingContext?.promise else {
52
+ let promise = self.pickingContext?.promise else {
53
53
  log.error("Picking context has been lost.")
54
54
  return
55
55
  }
@@ -101,12 +101,10 @@ public class DocumentPickerModule: Module, PickingResultHandler {
101
101
  return 0
102
102
  }
103
103
 
104
- let folderSize = contents.reduce(0) { currentSize, file in
104
+ return contents.reduce(0) { currentSize, file in
105
105
  let fileSize = getFileSize(path: path.appendingPathComponent(file)) ?? 0
106
106
  return currentSize + fileSize
107
107
  }
108
-
109
- return folderSize
110
108
  }
111
109
 
112
110
  private func readDocumentDetails(documentUrl: URL, copy: Bool) throws -> DocumentInfo {
@@ -132,11 +130,20 @@ public class DocumentPickerModule: Module, PickingResultHandler {
132
130
 
133
131
  let mimeType = self.getMimeType(from: documentUrl.pathExtension) ?? "application/octet-stream"
134
132
 
133
+ // Get last modified date or use current date if not available.
134
+ // This follows the Web API spec.
135
+ // https://developer.mozilla.org/en-US/docs/Web/API/File/lastModified
136
+ let lastModified = try? documentUrl.resourceValues(forKeys: [.contentModificationDateKey])
137
+ .contentModificationDate?.timeIntervalSince1970
138
+ // Convert to milliseconds and ensure integer value to match the Web API spec.
139
+ let lastModifiedMs = Int64((lastModified ?? Date().timeIntervalSince1970) * 1000)
140
+
135
141
  return DocumentInfo(
136
142
  uri: newUrl.absoluteString,
137
143
  name: documentUrl.lastPathComponent,
138
144
  size: fileSize,
139
- mimeType: mimeType
145
+ mimeType: mimeType,
146
+ lastModified: lastModifiedMs
140
147
  )
141
148
  }
142
149
 
@@ -1,13 +1,19 @@
1
1
  import ExpoModulesCore
2
2
 
3
+ // Disable swiftlint for redundant_optional_initialization.
4
+ // Optional initialization with nil is necessary for the Record constructors to work.
3
5
  internal struct DocumentPickerResponse: Record {
6
+ // swiftlint:disable:next redundant_optional_initialization
4
7
  @Field var assets: [DocumentInfo]? = nil
5
8
  @Field var canceled: Bool = false
6
9
  }
7
10
 
8
11
  internal struct DocumentInfo: Record {
9
12
  @Field var uri: String = ""
13
+ // swiftlint:disable:next redundant_optional_initialization
10
14
  @Field var name: String? = nil
11
15
  @Field var size: Int = 0
16
+ // swiftlint:disable:next redundant_optional_initialization
12
17
  @Field var mimeType: String? = nil
18
+ @Field var lastModified: Int64 = 0
13
19
  }
@@ -0,0 +1 @@
1
+ 44129972bd14b835fd756cb94515acbae8bbd10471a3ab5d3fb5b5235b8449b56f7b64bd9c82a7465596a06b852320e803e98fc2cf671a4cca6794f030a8b3fe
@@ -0,0 +1 @@
1
+ 6ad274ae505c7bde42f747a373c1f1fa4a9eae3c744a29532e110c0cbd8472085bdcaa95a569ec353d1ba0598e9a1793d3981147c0873b79d0686db32959a716
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "host.exp.exponent",
5
5
  "module": "expo.modules.documentpicker",
6
- "version": "13.1.6-canary-20250613-b29d676",
6
+ "version": "14.0.0-canary-20250630-547cd82",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -40,13 +40,13 @@
40
40
  ],
41
41
  "files": [
42
42
  {
43
- "name": "expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.aar",
44
- "url": "expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.aar",
45
- "size": 21237,
46
- "sha512": "6ae4ab6a6131a9156f6786cbe5031d742b79b1cafed76d8db6ea297e8da7227a883d7cd7a3840b3a3efe8286b98c1ef7af58991151a3019a4de0735c66832272",
47
- "sha256": "ee48e6931f44258597a07d54312fffa0be3e00a1274328bed294c8d035110700",
48
- "sha1": "87f537fc2824ef561696ab96dd8dda1e13835931",
49
- "md5": "f73abb3fdfe1e1a82a86c8c4dc46508f"
43
+ "name": "expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.aar",
44
+ "url": "expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.aar",
45
+ "size": 21768,
46
+ "sha512": "6ad274ae505c7bde42f747a373c1f1fa4a9eae3c744a29532e110c0cbd8472085bdcaa95a569ec353d1ba0598e9a1793d3981147c0873b79d0686db32959a716",
47
+ "sha256": "5730693eb3f4282d56db730416a5c1049752368612421d93455a288cc30cc937",
48
+ "sha1": "b84755a5a26208d5e537066e59f1d81f5023b996",
49
+ "md5": "b2c4cca445126ed7c09196d789968caa"
50
50
  }
51
51
  ]
52
52
  },
@@ -83,13 +83,13 @@
83
83
  ],
84
84
  "files": [
85
85
  {
86
- "name": "expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.aar",
87
- "url": "expo.modules.documentpicker-13.1.6-canary-20250613-b29d676.aar",
88
- "size": 21237,
89
- "sha512": "6ae4ab6a6131a9156f6786cbe5031d742b79b1cafed76d8db6ea297e8da7227a883d7cd7a3840b3a3efe8286b98c1ef7af58991151a3019a4de0735c66832272",
90
- "sha256": "ee48e6931f44258597a07d54312fffa0be3e00a1274328bed294c8d035110700",
91
- "sha1": "87f537fc2824ef561696ab96dd8dda1e13835931",
92
- "md5": "f73abb3fdfe1e1a82a86c8c4dc46508f"
86
+ "name": "expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.aar",
87
+ "url": "expo.modules.documentpicker-14.0.0-canary-20250630-547cd82.aar",
88
+ "size": 21768,
89
+ "sha512": "6ad274ae505c7bde42f747a373c1f1fa4a9eae3c744a29532e110c0cbd8472085bdcaa95a569ec353d1ba0598e9a1793d3981147c0873b79d0686db32959a716",
90
+ "sha256": "5730693eb3f4282d56db730416a5c1049752368612421d93455a288cc30cc937",
91
+ "sha1": "b84755a5a26208d5e537066e59f1d81f5023b996",
92
+ "md5": "b2c4cca445126ed7c09196d789968caa"
93
93
  }
94
94
  ]
95
95
  },
@@ -103,13 +103,13 @@
103
103
  },
104
104
  "files": [
105
105
  {
106
- "name": "expo.modules.documentpicker-13.1.6-canary-20250613-b29d676-sources.jar",
107
- "url": "expo.modules.documentpicker-13.1.6-canary-20250613-b29d676-sources.jar",
108
- "size": 4188,
109
- "sha512": "5ff342d5af582183d339ebf9259871097897246159fd14e9b324504f552e413deec0a73f4de9bcf764cea56eb74adc2b4904fc4c55a46363dc3491a0dd8b499f",
110
- "sha256": "ea8bcf17f70905d5a664af39497d1f47d6c35dbd15fdf1e5686d94caba293616",
111
- "sha1": "fea457edea02a2402b77b0567cdf58bf2ec0f121",
112
- "md5": "64d7909f101185c8e9e38b3166b24f60"
106
+ "name": "expo.modules.documentpicker-14.0.0-canary-20250630-547cd82-sources.jar",
107
+ "url": "expo.modules.documentpicker-14.0.0-canary-20250630-547cd82-sources.jar",
108
+ "size": 4515,
109
+ "sha512": "44129972bd14b835fd756cb94515acbae8bbd10471a3ab5d3fb5b5235b8449b56f7b64bd9c82a7465596a06b852320e803e98fc2cf671a4cca6794f030a8b3fe",
110
+ "sha256": "303ccd93da458a7674cc30fe6d702356b335ea9434fb798aad55627e1e9f79b2",
111
+ "sha1": "99dde6f9e1d5f51a35632e186df728389e629aba",
112
+ "md5": "24898a266e04418dfbfacd159df2960d"
113
113
  }
114
114
  ]
115
115
  }
@@ -0,0 +1 @@
1
+ 0bca95cb2164b79db5d49aa5b88b5fa3657f133602605d6f355e37c2ba3e69922b17bb608410294cacdc77a808f94d8351bdf6a87e49d04b51bceac60aff3070
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>host.exp.exponent</groupId>
11
11
  <artifactId>expo.modules.documentpicker</artifactId>
12
- <version>13.1.6-canary-20250613-b29d676</version>
12
+ <version>14.0.0-canary-20250630-547cd82</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.documentpicker</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ 3e2a8f478001b224ad7bbb335995ce73a8e492d1e7b2c39a226977a644d9bad81e92562bf13b443668fb49e7cd945e7dc63389f63c05dbd29c5a2297d0127732
@@ -3,11 +3,11 @@
3
3
  <groupId>host.exp.exponent</groupId>
4
4
  <artifactId>expo.modules.documentpicker</artifactId>
5
5
  <versioning>
6
- <latest>13.1.6-canary-20250613-b29d676</latest>
7
- <release>13.1.6-canary-20250613-b29d676</release>
6
+ <latest>14.0.0-canary-20250630-547cd82</latest>
7
+ <release>14.0.0-canary-20250630-547cd82</release>
8
8
  <versions>
9
- <version>13.1.6-canary-20250613-b29d676</version>
9
+ <version>14.0.0-canary-20250630-547cd82</version>
10
10
  </versions>
11
- <lastUpdated>20250613135939</lastUpdated>
11
+ <lastUpdated>20250630093945</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- fe071014cfa5dd04a348233b883a293a
1
+ 279523390235d8e7b9dc9cbf5e29545f
@@ -1 +1 @@
1
- b7b687bbc8e93f7bd20da47a181070c826087684
1
+ a2e755607bf710d9862cbd007dff6788c2ae5a6d
@@ -1 +1 @@
1
- 09a125bb09314fc0076ec2f0ce0164e3c18c5941cf288da9030b089d6a0f6f61
1
+ 6c97b502788f32c970443b3ce1a21e6bff44415f2cb8335af38873b0d00b29b1
@@ -1 +1 @@
1
- d1988aaf67e50d197bc901b97dd6122dddddc4a220d8a26aeb2e2d30013545b8e2455e1094c514e4033160cc859aad6c31342897bb1249ac0e1344ff2e242760
1
+ 41a02d15e8686de14641303f1c40cad2023cd50c15ef24731a8566af5e309f9a04a4de9eba6bf9a69757446172b8fa018dd6684f7d5246f5c76c021d0cb003c0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-document-picker",
3
- "version": "13.1.6-canary-20250613-b29d676",
3
+ "version": "14.0.0-canary-20250630-547cd82",
4
4
  "description": "Provides access to the system's UI for selecting documents from the available providers on the user's device.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -35,9 +35,9 @@
35
35
  "preset": "expo-module-scripts"
36
36
  },
37
37
  "devDependencies": {
38
- "expo-module-scripts": "4.1.8-canary-20250613-b29d676"
38
+ "expo-module-scripts": "4.1.9-canary-20250630-547cd82"
39
39
  },
40
40
  "peerDependencies": {
41
- "expo": "54.0.0-canary-20250613-b29d676"
41
+ "expo": "54.0.0-canary-20250630-547cd82"
42
42
  }
43
43
  }
@@ -6,7 +6,7 @@ export default {
6
6
  async getDocumentAsync({
7
7
  type = '*/*',
8
8
  multiple = false,
9
- base64 = true,
9
+ base64 = false,
10
10
  }: DocumentPickerOptions): Promise<DocumentPickerResult> {
11
11
  // SSR guard
12
12
  if (!Platform.isDOMAvailable) {
@@ -59,7 +59,7 @@ function readFileAsync(targetFile: File, base64: boolean = true): Promise<Docume
59
59
  const mimeType = targetFile.type;
60
60
  if (!base64) {
61
61
  resolve({
62
- uri: targetFile.webkitRelativePath,
62
+ uri: URL.createObjectURL(targetFile),
63
63
  mimeType,
64
64
  name: targetFile.name,
65
65
  lastModified: targetFile.lastModified,
@@ -73,9 +73,10 @@ function readFileAsync(targetFile: File, base64: boolean = true): Promise<Docume
73
73
  reject(new Error(`Failed to read the selected media because the operation failed.`));
74
74
  };
75
75
  reader.onload = ({ target }) => {
76
- const uri = (target as any).result;
76
+ const base64 = (target as any).result;
77
77
  resolve({
78
- uri,
78
+ uri: URL.createObjectURL(targetFile),
79
+ base64,
79
80
  mimeType,
80
81
  name: targetFile.name,
81
82
  lastModified: targetFile.lastModified,
package/src/types.ts CHANGED
@@ -12,6 +12,8 @@ export type DocumentPickerOptions = {
12
12
  * which allows other Expo APIs to read the file immediately. This may impact performance for
13
13
  * large files, so you should consider setting this to `false` if you expect users to pick
14
14
  * particularly large files and your app does not need immediate read access.
15
+ * @platform ios
16
+ * @platform android
15
17
  * @default true
16
18
  */
17
19
  copyToCacheDirectory?: boolean;
@@ -48,14 +50,22 @@ export type DocumentPickerAsset = {
48
50
  */
49
51
  mimeType?: string;
50
52
  /**
51
- * Timestamp of last document modification.
53
+ * Timestamp of last document modification. [Web API specs](https://developer.mozilla.org/en-US/docs/Web/API/File/lastModified)
54
+ * The lastModified provides the last modified date of the file as the number
55
+ * of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files
56
+ * without a known last modified date return the current date.
52
57
  */
53
- lastModified?: number;
58
+ lastModified: number;
54
59
  /**
55
60
  * `File` object for the parity with web File API.
56
61
  * @platform web
57
62
  */
58
63
  file?: File;
64
+ /**
65
+ * Base64 string of the file.
66
+ * @platform web
67
+ */
68
+ base64?: string;
59
69
  };
60
70
 
61
71
  /**
@@ -1 +0,0 @@
1
- 5ff342d5af582183d339ebf9259871097897246159fd14e9b324504f552e413deec0a73f4de9bcf764cea56eb74adc2b4904fc4c55a46363dc3491a0dd8b499f
@@ -1 +0,0 @@
1
- 6ae4ab6a6131a9156f6786cbe5031d742b79b1cafed76d8db6ea297e8da7227a883d7cd7a3840b3a3efe8286b98c1ef7af58991151a3019a4de0735c66832272
@@ -1 +0,0 @@
1
- 0ed0a3fb2de9c74c655c6060b03004e42f6e6c5815ed19235f041157587537ce03ae140b16ec913d88611a578e0df635ed58d8c9bb26d9b6dd649aa7594257b5
@@ -1 +0,0 @@
1
- b053ac6132fc45f2a02ab1e518e4f8f6d4c5bca528eaf571fd9579a50cdc5cccb1171cb88e258aafe3da9ac6ca3d16ce16f27f4745a3a832db34891e123fbda7