【发布时间】:2017-10-04 13:03:48
【问题描述】:
我是 typescript 的新手,正在尝试从我的移动 SD 卡上传图像。浏览图像时我正在获取图像路径。当我将它与表单数据一起传递时,None 正在返回。如果有人伸出援助之手来解决这个问题,那就太好了。
我正在使用“nativescript-imagepicker”库从 SD 卡获取图像..
sendPicture(uri: string, modelContext: any){
let _formData = new FormData();
_formData.append("profile_image", uri);
let body = _formData;
updateAvatarService(this.userToken,body).subscribe(data => {
});
}
updateAvatarService(token,body): Observable<any> {
return this.httpClass.patchMethodWithToken(URL,token,body)
.map(response => {
return response;
})
}
patchMethodWithToken(url: string, token: string, data: Object ) {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Authorization', "Token " + token);
headers.append('Content-Disposition', "form-data");
let options = new RequestOptions({ headers: headers });
if (this.checkNetworkConnection()) {
return this.http
.patch(url, JSON.stringify(data), options)
.map(response => {
return response.json();
})
.catch(this.handleErrors);
}
}
【问题讨论】:
-
使用代码提供更多信息
-
请检查我现在添加的代码..
标签: android ios typescript mobile nativescript