'{“errors”:{“base”:[“Forbidden. Need user.”]}}'

强颜欢笑 提交于 2019-12-13 05:18:16

问题


Hello everyone i am trying to upload user profile pic it shows me '{"errors":{"base":["Forbidden. Need user."]}}' this error Please let me know what i am doing wrong

QBContent.uploadFileTask(profilePic, true, new QBCallbackImpl() {
    @Override
    public void onComplete(Result result) {
        if (result.isSuccess()) {
            // get uploaded file 
            QBFileUploadTaskResult fileUploadTaskResult = (QBFileUploadTaskResult) result;
            QBFile qbFile = fileUploadTaskResult.getFile();
            int uploadedFileID = qbFile.getId();

            // Connect image to user
            QBUser user = new QBUser();
            user.setId(userID);
            user.setFileId(uploadedFileID);

            QBUsers.updateUser(user, new QBCallbackImpl() {
                @Override
                public void onComplete(Result result) {
                    if (result.isSuccess()) {
                        // Profile picture has changed!
                    } else {
                        Log.e("Errors",result.getErrors().toString()); 
                    }
                } 
            });
        } else {
            Log.e("Errors",result.getErrors().toString()); 
        }
    }
});

回答1:


there are two senario 1)you are not a logged in user 2)or may be session you created is expired for that purpose you need to signin with quickblox again




回答2:


Either you do not have required permission there. or you are not a registered user.




回答3:


You should login your user again and only after that attach the file.I had similar situation when i took a picture using camera. I did this. Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivity(intent); CameraActivity was started and connection was lost, so you need to reconnect if you want to upload the file.




回答4:


Try doing this before calling upload

QBUsers.signIn(Constants.user);


来源:https://stackoverflow.com/questions/25968544/errorsbaseforbidden-need-user

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