我正在尝试使用FileTransfer本机插件将文件和其他请求参数一起发送到我的后端服务。但是,当我运行文件传输请求时,响应是FileTransferError,并且每个参数都为空。这是我的方法:
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();
});
}