我是新来的打字稿,并尝试从移动SD卡上传图片。浏览图像时,我正在获取图像路径。当我通过这个表单数据时,无返回。如果有人帮助解决问题,这将是非常棒的。使用移动表单数据的打字稿图片上传返回无
我使用“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);
}
}
提供代码 – Dlucidone
更多信息请检查我现在已经增加了代码.. – vishnuc156