How do I send two images that respond to different parameters, with two other string values?

0

I have the following code in Ionic 3.9:

const fileTransfer: FileTransferObject = this.transfer.create();

    let optionsSend: FileUploadOptions = {
       fileKey: "9602",
       fileName: "filename",
       chunkedMode: false,
       mimeType: "image/jpg",
       params : {
         'texto': 'hola',
         'nombre': 'chau'             
       },
       headers: new Headers({
         'Content-Type': 'application/x-www-form-urlencoded',
       })

    }

fileTransfer.upload(this.imagetoSend_1 , aquiUrlApi, optionsSend)
 .then((data) => {

   alert("Exito: " + data);
 }, (err) => {

   alert("Error: " + JSON.stringify(err));

 });

I want to send the following values:

  • To the parameter "9602" the value "image1" which is an image,
  • To the parameter "9603" the value "image2" which is another image,
  • To the "text" parameter the value "hello" which is a string,
  • To the parameter "name" the value "chau" which is an image.

The idea is that you can do it in a single call to the function, that is, hit the API once.

The API works well, it's been tested since Postman.

How do I send two images with two other parameters with the use of "FileTransferObject"?

    
asked by Alan Nexus 06.12.2018 в 00:28
source

0 answers