react-native-blob-util icon indicating copy to clipboard operation
react-native-blob-util copied to clipboard

Handle externalstorage.documents in getRealPathFromURI

Open Airyzz opened this issue 1 year ago • 2 comments

Related to #365

I doubt this is really a recommended way to do things, but it's okay for my use case and figured I would share in case others find it useful.

Airyzz avatar Nov 24 '24 02:11 Airyzz

Did you test if it works with normalizing the path as it does in other locations?

RonRadtke avatar Nov 27 '24 21:11 RonRadtke

This patch works, but in my case the method PathResolver::getRealPathFromURI fails for this branch:

if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
    ...
    if (isExternalStorageDocument(uri)) {
        ...
        if ("primary".equalsIgnoreCase(type)) {
            // this will return the package's directory and not the external storage directory
            File dir = context.getExternalFilesDir(null);

and this must be changed to File dir = Environment.getExternalStorageDirectory(); aswell.

ClaudiuHBann avatar Feb 16 '25 23:02 ClaudiuHBann