Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read PDF, .Docx from Internal Storage using cordova.file.externalRootDirectory for Android 11 #508

Closed
ragul02 opened this issue Dec 16, 2021 · 3 comments · Fixed by #513

Comments

@ragul02
Copy link

ragul02 commented Dec 16, 2021

Bug Report

Problem

Not able to read PDF and .Docx files from location file:///storage/emulated/0/Download/. Also not able to read files recursively inside directories, Returning array length of '0'.

What is expected to happen?

Should return all files under location file:///storage/emulated/0/Download/

What does actually happen?

Able to read only .jpeg, .gif, .mp3, ,mp4 files.

Information

Command or Code

listFilesinFolder(folderName) {
this.file.listDir(this.file.externalRootDirectory, 'Download'+'/').then((filesList) => {
console.log('filesList-->', filesList);
if (filesList.length !== 0) {
Promise.all(filesList.map(async (file) => {
if (file.isDirectory) {
console.log('Directory', file);
this.listFilesinFolder(file.fullPath.substring(1));
} else if (file.isFile === true) {
console.log('file', file);
}
}
})));
}

Environment, Platform, Device

Android 11

Version information

"@ionic-native/file": "^5.36.0",
"cordova-plugin-file": "^6.0.2",

Included below in config.xml:




@ragul02
Copy link
Author

ragul02 commented Dec 16, 2021

Included below in config.xml:

<preference name="AndroidPersistentFileLocation" value="Internal" />
  <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
            <application android:networkSecurityConfig="@xml/network_security_config" />
            <application android:requestLegacyExternalStorage="true" android:usesCleartextTraffic="true" />
        </edit-config>

@edvenkat
Copy link

@ragul02 - i have tried but not working. any other idea

@subranil
Copy link

Does anyone have solution for that

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 a pull request may close this issue.

3 participants