(Ionic) Cordoba file plugin error while trying to read file

So, I'm currently trying to read the audio file that I just saved in the application directory (Android) through the file cordova plugin, but I continue to get the same error code 5, which means "ENCODING_ERR".

This is how I create the file and start recording

start() { this.filename = this.file.externalDataDirectory.replace(/file:\/\//g, ''); this.mediaobject = this.media.create(this.filename + 'audioprofile' + '.3gp'); this.mediaobject.startRecord(); } 

This is how I stop recording and saving a file

 stop() { this.mediaobject.stopRecord(); this.mediaobject.release(); ... 

And this is where I got stuck: right after saving it, I need it to be like String, so I'm trying to read it ( alert(content) should show me this string)

 stop() { this.mediaobject.stopRecord(); this.mediaobject.release(); this.storage.get("uid").then((id) => { try{ this.file.readAsDataURL(this.filename,'audioprofile'+'.3gp').then((filecontent)=>{ alert(filecontent); },(err)=>{ alert(err.code); }) } ` 

After some research, I found out that this PROBABLY means that I am not giving the correct path for it, but I tried everything, any combinations of "filename" and "filepath" were made, even adding the prefix that was deleted at startup ().

I want to know if someone was able to read the file with this cordova plugin, and if you did, please help me.

Thanks in advance, this is my first post here \ o / (although I always used the site, I liked the guys).

+5
source share
1 answer

Well, I managed to do this with the File-Path plugin, it resolves the Path for your file in such a way that the File Plugin understands and can reach the file, then you just need to manipulate it the way you want.

0
source

Source: https://habr.com/ru/post/1273292/


All Articles