File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
android/src/main/kotlin/com/mr/flutter/plugin/filepicker Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -503,7 +503,21 @@ object FileUtils {
503503 private fun getPathFromTreeUri (uri : Uri ): String {
504504 val docId = DocumentsContract .getTreeDocumentId(uri)
505505 val parts = docId.split(" :" )
506- return " ${Environment .getExternalStorageDirectory()} /${parts.last()} "
506+
507+ // Check if the URI corresponds to external storage
508+ return if (parts.size > 1 ) {
509+ val volumeId = parts[0 ]
510+ val path = parts[1 ]
511+
512+ // Map volume ID to external storage path
513+ if (" primary" .equals(volumeId, ignoreCase = true )) {
514+ " ${Environment .getExternalStorageDirectory()} /$path "
515+ } else {
516+ " /storage/$volumeId /$path "
517+ }
518+ } else {
519+ " ${Environment .getExternalStorageDirectory()} /${parts.last()} "
520+ }
507521 }
508522
509523 @JvmStatic
You can’t perform that action at this time.
0 commit comments