Kinvey AngularJS图片上传内容类型头 [英] Kinvey AngularJS Image Upload Content-Type Header
问题描述
我使用Kinvey的AngularJS库。现在,我可以成功上传到图片Kinvey的的文件的。我看到我的映像文件上传成功。问题是我是从上传功能的承诺得到一个错误。
图像文件:
$ scope.onFileSelect =功能(元素){
如果(element.files [0]){
$ scope.selectedImage = element.files [0];
}
的console.log($ scope.selectedImage);
};
上传功能:
VAR承诺= $ kinvey.File.upload($ scope.selectedImage,{
mime类型:$ scope.selectedImage.type,
大小:$ scope.selectedImage.length
});promise.then(功能(响应){
的console.log('上传图片成功);
uikit.notificationTop('上传新形象','成功');
的console.log(响应);
},功能(错误){
uikit.notificationTop('错误在上传新形象,危险);
的console.log(ERR);
});
这是我收到的错误:
错误:响应Content-Type头被设置为text / html;字符集= UTF-8。预计它被设置为application / JSON。
块引用>解决方案Kinvey的团队注意到了这个错误问题,并固定它。
1.6.8 - 2016年2月10日搜索结果
修正:不检查响应类型从谷歌文件上传。修正:不要在登录请求发送一个空的用户名/密码
块引用>感谢Kinvey!
I'm using the AngularJS library of Kinvey. Right now, I can successfully upload an image to Kinvey's Files. I see that my image file is successfully uploaded. The problem is I'm getting an error from the promise of the upload function.
Image file:
$scope.onFileSelect = function(element) { if (element.files[0]) { $scope.selectedImage = element.files[0]; } console.log($scope.selectedImage); };
Upload function:
var promise = $kinvey.File.upload($scope.selectedImage, { mimeType : $scope.selectedImage.type, size : $scope.selectedImage.length }); promise.then(function(response) { console.log('Uploaded image successfully'); uikit.notificationTop('Uploaded new image', 'success'); console.log(response); }, function(err) { uikit.notificationTop('Error in uploading new image', 'danger'); console.log(err); });
This is the error I'm getting:
Error: Response Content-Type header is set to text/html; charset=UTF-8. Expected it to be set to application/json.
解决方案Kinvey's team noticed this bug issue and fixed it.
1.6.8 - Feb 10, 2016
Bugfix: Do not check response type for file uploads from Google. Bugfix: Do not send an empty username/password in a login request.Thanks Kinvey!
这篇关于Kinvey AngularJS图片上传内容类型头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!