Convert URI to Object

Hi,

i’m actually using cordova phonegap plugin to filepick on iOS an audio file.

this.filePicker.pickFile()

This gives me back an URI which i struggle converting to the same file type as my working Android code :
.
.
.
I have a provider which send to backend a _POST and a _FILES like this :

  providerFunction(objectA, file){
	 
    let body = { id : objectA.id};
    body['file'] = file;

    return this.api.post('mypathtoendpoint.php', body).map((res : any) => {

This is working good with Android because i use nativeElement with a function that send
“typescriptFunction($event.target.files)” which i get as a FileList like this :

typescriptFunction(files: FileList){

this.myService.providerFunction(this.file, files.item(0))

But as i get an URI from :

this.filePicker.pickFile()
				.then(uri =>

i tried to convert to a new File(path, type) but this is not the same object type.

Would something like this works ?

	this.files.resolveLocalFilesystemUrl(this.fileURI).then((fileEntry: fileEntry) => {
      var myFile = fileEntry.files;
    }, (err) => {
      console.log("Error");
    })

console.log(typeof myFile); //   Object

Thank you

1 Like

Did you find a solution for this?