Kinvey AngularJS Image Upload Content-Type Header

柔情痞子 提交于 2019-12-24 15:54:41

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!