Ionic native file -- problems accessing files

Hi there,

I’m using the ionic native file plugin and I’m simply trying to make use of the readAsArrayBuffer(path, file) method, but I think I’m struggling with the syntax of how to use it!

So I’m running on an android phone, which I have uploaded a test file at the root directory… something like this:

‘testFiles/testFile.testFileFormat’

When I run the command: this.file.listDir(this.file.externalRootDirectory, 'testFiles') I get an array containing my ‘testFile.testFileFormat’

So I know it’s there, and I know the native file plugin can see it… but how the heck do I use readAsArrayBuffer to open it? I tried: readAsArrayBuffer(this.file.externalRootDirectory + 'testFiles', 'testFile.testFileFormat') but I get a encoding error…

Any suggestions?

Ok… so this was just a typo in my code somewhere… Retested with

this.file.readAsArrayBuffer(this.file.externalRootDirectory + 'testFiles', 'testFile.testFileFormat')

And it works as expected.

1 Like