I am trying to send a file along with other request params to my backend service using the FileTransfer native plugin. However, when I run the file transfer request, the response is a FileTransferError and each of the params is null. Here is my method:
mediaUpload(product) {
console.log(this.picture);
const fileTransfer: FileTransferObject = this.transfer.create();
let options: FileUploadOptions = {
fileName: this.title,
headers: {},
params: {
productId: product.id,
imageTitle: this.title,
}
};
fileTransfer.upload(this.picture, this.createImageURL)
.then((data) => {
// success
console.log(data);
this.loader.dismiss();
if (data.response === "false") {
alert('Media upload failed!');
}
else {
this.navCtrl.setRoot(TabsPage);
}
}, (err) => {
// error
alert("Network error with image upload. Please try again later!");
console.log(err);
this.loader.dismiss();
});
}