How to Read File as Array From SD Card with cordova-plugin-file


I use audio files in my app that I need to get as an buffer array. For this I let the user choose a file (using Ionic/Cordova FileChooser Plugin) and then I get an URL like:


After that, I sent this to Cordova Plugin File resolveNativePath function and I get a Path Like:

file:///storage/emulated/0/Prueba interno/Interno, Teddybär, Dreh Dich Um__320kbps.mp3

Here I make my audioFileInfo Object

audioFileInfo = {name: "Interno, Teddybär, Dreh Dich Um__320kbps.mp3",
                 originalPath: "content://",
                  path: "file:///storage/emulated/0/Prueba interno"}

and finally I call filePlugin.readAsArrayBuffer(audioFileInfo.path, to get the buffer array.

It works ok when the file is in the device internal storage, but when the file comes from the SDCard it does not work because the readAsArrayBuffer returns “not found”.

SD Card:

File Chooser URL



file:///sdcard/Música Dana/1 - Teddybär, Teddybär, Dreh Dich Um__320kbps.mp3


audioFileInfo = {
    name :"1 - Teddybär, Teddybär, Dreh Dich Um__320kbps.mp3"
    originalPath : "content://",
    path : "file:///sdcard/Música Dana"


FileError {code: 1, message: "NOT_FOUND_ERR"}

I have tried FilePlugins’s resolveLocalFilesystemUrl() and I get this Entry object:

    filesystem: {
        name: "content",
        root: {
            filesystem {
                name: "content",
                root: "...."

        fullPath: "/",
        isDirectory: true,
        isFile: false,
        name: "",
        nativeURL: "content://",
    fullPath: "/úsica Dana/1 - Teddybär, Teddybär, Dreh Dich Um__320kbps.mp3",
    isDirectory: false,
    isFile: true,
    name: "1 - Teddybär, Teddybär, Dreh Dich Um__320kbps.mp3",
    nativeURL: "content://",

Bue I have no idea what to use as path in the first parameter of the readAsArrayBuffer function.

If I use fullPath and name it throws encoding error.
If I get just the “path” without the name from fullPath, it also throws encoding error.

Does anybody had a similar experience?


Facing similar problem. External Storage (sdcard) is not both the encodeUrl or decodeUrl way. Decoded: file:///sdcard/New Folder (2)/Testing Files/download.jpeg and Encoded: file:///sdcard/New%20Folder%20(2)/Testing%20Files/download.jpeg

I am trying to convert a file in sdcard into base64 format:
this.base64.encodeFile(imgUri).then(). It is returning me empty string. But if i choose the file from internal storage its ok. imgUri is the sdcard path of the file. Please help somebody.