File transfer to wordpress


#1

Hi I am working in project to upload post and feature image , Now after a lot of searching I can now Upload post and image but now I can’t know how can I use this image for this post , I am trying to get image ID after uploading but without any luck , I think if I get image id I can use it with new post ,
this is my code for uploading image

public uploadImage(img){
  let options: FileUploadOptions = {
     fileKey: 'file',
     fileName: 'name.jpg',
     mimeType: 'image/jpeg',
     headers :{
         'Authorization': `Bearer ${this.userprovider.auth}`,
       'Content-Disposition':'attachment'
     }  
  }
    const fileTransfer: FileTransferObject = this.transfer.create();
  fileTransfer.upload(img, 'http://lets-cook.xyz/wp-json/wp/v2/media', options)
   .then((data) => {
     console.log(data)  
   }, (err) => {
console.log(err) 
    })   
  }

and this is my code for new post

createReport(score: string, report: string, category: number[] = []) {
   
    this.events.publish('wordpress:savestatus', { state: 'saving' });

    let data = {
      title: score,
      excerpt: report,
      content: report,
      categories: category,
      status: 'pending'
    };

    this.http.post('http://lets-cook.xyz/wp-json/wp/v2/posts', data).subscribe(data => {
  
      this.events.publish('wordpress:savestatus', { state: 'finished' });
      this.events.publish('wordpress:createdreport');

    }, error => {
      this.events.publish('wordpress:savestatus', { state: 'error', message: error });
    });
  }

and I got response from uploading image with the id, but I don’t know how can I take this ID

Object {response: "{"id":853,"date":"2017-08-02T17:35:04","date_gmt":…"https:\/\/api.w.org\/{rel}","templated":true}]}}", responseCode: 201, objectId: "", bytesSent: 104558}

Thanks


#2

Any Solution for your problem??
what is the img type? (data_url or File_uri)