breautek commented on issue #565: URL: https://github.com/apache/cordova-plugin-file/issues/565#issuecomment-1502377154
> The files I'm trying to open are on the device itself and not on external storage. Android has 2 storage mediums, internal and external storage. Both can be on the device. External storage are generally attached to an SD card (will have a `/sdcard/...` path, however most devices will also emulate external storage if the sdcard is not present, or not supported (generally uses a `/storage/emulated/0/...` path). So a filepath like `file:///storage/emulated/0/Download/1671641692909.jpg` tells me that you're working with external storage, and thus [Scoped Storage](https://source.android.com/docs/core/storage/scoped) rules applies. Documents have stricter rules than media files, so if the app has `READ_EXTERNAL_STORAGE` permission granted (and this plugin will request it when appropriate), you may read media off the external storage (subject to permissions set my the app who wrote that media file). However, I don't `READ_EXTERNAL_STORAGE` applies to document files, such as those that are generally found in `Downloads/` or otherwise. I believe the only way to read document files is via the native MediaStore APIs which the file plugin does not implement (they aren't really friendly to file-like API cause they don't really share the same concepts). This is also kinda further enforced that in API 33 and later `READ_EXTERNAL_STORAGE` becomes obsolete in favour of 3 new permissions, `READ_MEDIA_IMAGES`, `READ_MEDIA_AUDIO`, READ_MEDIA_VIDEO`, however there is no explicit `READ` permission for documents. This is why I suggested something like https://www.npmjs.com/package/cordova-plugin-saf-mediastore which contains APIs like `readFile(uri:string):Promise<ArrayBuffer>`, so the plugin not only provides the way to choose files via MediaStore & the file picker, but to also read and get the contents of the files, or write/overwrite... whereas https://www.npmjs.com/package/cordova-plugin-filechooser looks like only allows you to select files and returns a `content` URL, which thie cordova-plugin-file can only use if it leads to a file that is readable using filesystem APIs. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
