Ionic 2 FileTransferError:所有响应参数都为空;使用livereload与Android设备

时间:2017-08-23 15:47:26

标签: angular cordova ionic-framework ionic2 cordova-plugins

我正在尝试使用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();
        });

}

0 个答案:

没有答案