问题
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.
回答1:
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!
来源:https://stackoverflow.com/questions/35323746/kinvey-angularjs-image-upload-content-type-header