在我的Ionic 2应用程序中,我使用cordova-plugin-camera
拍摄一张照片,其中我检索的照片是FILE_URL
(本地设备的图像位置),效果很好。FileTransfer返回所有属性为'null'的错误
这给我的网址,像这样拍摄图片的相机时:file:///storage/emulated/0/Android/....../1234.jpg
而且这样选择从库中的图像时:content://com.android.providers.media.documents/document/image%232312
现在我想要使用上传这个图片cordova-plugin-file-transfer
。
我上传的功能是这样的:
upload(){
let options: FileUploadOptions = {
fileKey: 'file',
fileName: 'my_image.jpg',
headers: {'X-CSRF-Token': localStorage.getItem('u:token')}
}
alert(this.imageSrc);
this.fileTransfer.upload(this.imageSrc, encodeURI(this.API_URL), options, true)
.then(data => {
alert("d:"+JSON.stringify(data));
}, err => {
alert("E:"+JSON.stringify(err));
});
}
但是我收到一个错误对象持有以下
{
"code" : "null",
"source" : "null",
"target" : "null",
"http_status" : "null",
"body" : "null",
"exception" : "null"
}
注:没有额外的误差修改正在throwm
你确定它不是一个服务器端的问题? –
@suraj我期望一个'http_status'的值为'500',如果是这样的话,甚至是'404'如果它不存在 – Ivaro18
true ..但类似cors的问题会给你null/0状态 –