0

I have an array like this.

["file:///data/user/0/io.ionic.starter/files/1542283317507.jpg",null,
 "file:///data/user/0/io.ionic.starter/files/1542283320931.jpg"]

I'm trying to send this array(name's final) via fileTransfer upload function. But it returns error. Btw it's workin' for single image which out of array. How can i send that's array.

  fileTransfer.upload(final, url, options).then(
  data => {
    console.log(data);

    this.presentToast("Image succesful uploaded.");
  },
  err => {
    this.presentToast("Error while uploading file.");
  }
);

}

Thanks for helping!

1 Answer 1

1

You can try this, not tested but it should work.

var promises = [];
var filesArray = ["file:///data/user/0/io.ionic.starter/files/1542283317507.jpg",
 "file:///data/user/0/io.ionic.starter/files/1542283320931.jpg"];

filesArray.forEach((element) => {
  var uploadPromise = fileTransfer.upload(<YOUR_FINAL>, element, <YOUR_OPTIONS>);
  promises.push(uploadPromise);
});


Promise.all(promises)
.then((result) => {
  console.log('All files uploaded !');
}
Sign up to request clarification or add additional context in comments.

1 Comment

sorry for late answer. but it didn't work. thanks for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.