从相机的Ionic FileTransfer错误代码:3到服务器托管

时间:2018-07-23 09:35:20

标签: angular ionic-framework continuous-integration

我有用于将图像从相机上传到服务器(本地)的代码,并且可以正常工作

fileTransfer.upload(imageData, 'http://192.168.0.100/profile/upload', options1).then((data) => {
                    // success
                    alert("Success");
                }, (err) => {
                    // error
                    alert("error"+JSON.stringify(err));
                });

然后将URL从本地更改为托管,但出现这样的错误

error {"code":3, "source":"file:///storage/...","target":http://mylink.com/profile/upload,"http_status":null,"body":null,"exception":"unexpected end of stream on com.android.okhttp_Address@51fa1429"

该如何解决?

1 个答案:

答案 0 :(得分:1)

在选项中添加chunkedMode: false。和这样的代码

let options1: FileUploadOptions = {
                    mimeType: 'multipart/form-data',
                    httpMethod: 'POST',
                    chunkedMode: false,
                   fileKey: 'file'
                }