@@ -25,16 +25,7 @@ class UriHelper {
25
25
}
26
26
// DownloadsProvider
27
27
else if ( UriHelper . isDownloadsDocument ( uri ) ) {
28
- id = DocumentsContract . getDocumentId ( uri ) ;
29
- // Since Oreo the downloads id may be a raw string,
30
- // containing the file path:
31
- if ( id . indexOf ( "raw:" ) !== - 1 ) {
32
- return id . substring ( 4 , id . length ) ;
33
- }
34
- contentUri = android . content . ContentUris . withAppendedId (
35
- android . net . Uri . parse ( "content://downloads/public_downloads" ) , long ( id ) ) ;
36
-
37
- return UriHelper . getDataColumn ( contentUri , null , null ) ;
28
+ return UriHelper . getDataColumn ( uri , null , null ) ;
38
29
}
39
30
// MediaProvider
40
31
else if ( UriHelper . isMediaDocument ( uri ) ) {
@@ -73,15 +64,17 @@ class UriHelper {
73
64
74
65
private static getDataColumn ( uri : android . net . Uri , selection , selectionArgs ) {
75
66
let cursor = null ;
76
- let columns = [ android . provider . MediaStore . MediaColumns . DATA ] ;
77
67
let filePath ;
68
+ let columns = [ "_display_name" ] ;
78
69
79
70
try {
80
71
cursor = this . getContentResolver ( ) . query ( uri , columns , selection , selectionArgs , null ) ;
81
72
if ( cursor != null && cursor . moveToFirst ( ) ) {
82
73
let column_index = cursor . getColumnIndexOrThrow ( columns [ 0 ] ) ;
83
74
filePath = cursor . getString ( column_index ) ;
84
75
if ( filePath ) {
76
+ const dl = android . os . Environment . getExternalStoragePublicDirectory ( android . os . Environment . DIRECTORY_DOWNLOADS ) ;
77
+ filePath = `${ dl } /${ filePath } ` ;
85
78
return filePath ;
86
79
}
87
80
}
0 commit comments