@@ -9,6 +9,7 @@ import android.os.Build
99import android.os.Environment
1010import android.provider.DocumentsContract
1111import android.provider.MediaStore
12+ import android.util.Log
1213import java.io.*
1314
1415/* *
@@ -62,24 +63,31 @@ object FileUriUtils {
6263 }
6364 }
6465 isDownloadsDocument(uri) -> {
65- val fileName = getFilePath(context, uri)
66+ /* val fileName = getFilePath(context, uri)
6667 if (fileName != null) {
6768 val path = Environment.getExternalStorageDirectory()
6869 .toString() + "/Download/" + fileName
6970 if (File(path).exists()) {
7071 return path
7172 }
72- }
73+ }*/
7374
7475 var id = DocumentsContract .getDocumentId(uri)
7576 if (id.contains(" :" )) {
7677 id = id.split(" :" )[1 ]
7778 }
78- val contentUri = ContentUris .withAppendedId(
79- Uri .parse(" content://downloads/public_downloads" ),
80- java.lang.Long .valueOf(id)
81- )
82- return getDataColumn(context, contentUri, null , null )
79+ if (id.isNotBlank()) {
80+ return try {
81+ val contentUri = ContentUris .withAppendedId(
82+ Uri .parse(" content://downloads/public_downloads" ),
83+ java.lang.Long .valueOf(id)
84+ )
85+ getDataColumn(context, contentUri, null , null )
86+ } catch (e: NumberFormatException ) {
87+ Log .i(" ImagePicker" , e.message.toString())
88+ null
89+ }
90+ }
8391 }
8492 isMediaDocument(uri) -> {
8593 val docId = DocumentsContract .getDocumentId(uri)
0 commit comments