Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70434

Convert URI to Object

$
0
0

@Lifistic wrote:

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

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70434

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>