Skip to content

@7.0.0 resolveLocalFileSystemURL a content uri get a FileError  #525

@lovelyelfpop

Description

@lovelyelfpop

Bug Report

Problem

resolveLocalFileSystemURL a content uri get FileError 

What is expected to happen?

const uri = 'content://com.android.providers.media.documents/document/image%3A189210';
// or 
// const uri = 'https://localhost/__cdvfile_content__/com.android.providers.media.documents/document/image%3A189210';
window.resolveLocalFileSystemURL(uri, function (fileEntry) {
    console.log(fileEntry); 
}, function(err) {
    console.log(err)
});

It got a FileError (code 1, not found)

What does actually happen?

It should log the fileEntry in the console

Information

Environment, Platform, Device

Redmi K30 pro, Android 11

Version information

[email protected]
[email protected]
[email protected]

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Reason

The code below inside function toNativeUri in org\apache\cordova\file\ContentFilesystem.java

String authorityAndPath = inputURL.uri.getEncodedPath().substring(this.name.length() + 2);

got e_content__/com.android.providers.media.documents/document/image%3A189210

It should be
com.android.providers.media.documents/document/image%3A189210

The right code is:

String encodedPath = inputURL.uri.getEncodedPath();
String authorityAndPath = encodedPath.substring(encodedPath.indexOf(this.name) + 1 + this.name.length() + 2);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions