Javascript 正在尝试在Ionic 2中上载FileTransfer映像和用户数据?
我正在尝试向我的端点发送用户图像和所有用户数据。我从设备库中获取用户图像,其路径如下:Javascript 正在尝试在Ionic 2中上载FileTransfer映像和用户数据?,javascript,ionic-framework,ionic-native,Javascript,Ionic Framework,Ionic Native,我正在尝试向我的端点发送用户图像和所有用户数据。我从设备库中获取用户图像,其路径如下: let imageLocation = file:///data/user/0/.../cache/tmp_IMG-20170907-WA0026534743393.jpg; 然后我有了用户对象: this.dataUser = { name: "jhon", email: "jhon@live.com", id: 123 }; 现在我创建TransferObject对象并实现上传
let imageLocation = file:///data/user/0/.../cache/tmp_IMG-20170907-WA0026534743393.jpg;
然后我有了用户对象:
this.dataUser = {
name: "jhon",
email: "jhon@live.com",
id: 123
};
现在我创建TransferObject对象并实现上传功能:
const fileTransfer: TransferObject = this.transfer.create();
let options: FileUploadOptions = {
fileKey: 'avatar',
httpMethod: 'PUT',
headers: { 'Authorization': 'JWT ' + token },
params: this.dataUser
}
return new Promise(resolve => {
fileTransfer.upload(imageLocation, URL, options, true)
.then((data) => {
console.log('upload success -> ', data);
resolve(data);
}, error => {
console.log(error);
});
});
当函数被执行时,上传似乎是成功的,因为它返回了responseCode=200的对象,但是response键包含一个空字符串,为什么
这是我的上传输出:
{bytesSent: 488723, responseCode: 200, response: "{"avatar": null, "name": "", "email": "", "id": null}"}