Skip to content

Handle externalstorage.documents in getRealPathFromURI - #389

Open
Airyzz wants to merge 2 commits into
RonRadtke:masterfrom
Airyzz:master
Open

Handle externalstorage.documents in getRealPathFromURI#389
Airyzz wants to merge 2 commits into
RonRadtke:masterfrom
Airyzz:master

Conversation

@Airyzz

@Airyzz Airyzz commented Nov 24, 2024

Copy link
Copy Markdown

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.

these were causing issues, dont know what they do
@RonRadtke

Copy link
Copy Markdown
Owner

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

@ClaudiuHBann

ClaudiuHBann commented Feb 16, 2025

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants