Ionic文件从相机传输错误代码:3到服务器主机



我有从相机上传图像到服务器(LOCAL(的代码,它可以正常工作

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"

如何修复?

在选项中添加chunkedMode: false。和类似的代码

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

相关内容

最新更新