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

2019-09-17 03:55发布

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()); 
        }
    }
});

4条回答
叼着烟拽天下
2楼-- · 2019-09-17 04:08

Try doing this before calling upload

QBUsers.signIn(Constants.user);
查看更多
来,给爷笑一个
3楼-- · 2019-09-17 04:19

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

查看更多
Animai°情兽
4楼-- · 2019-09-17 04:23

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

查看更多
Juvenile、少年°
5楼-- · 2019-09-17 04:32

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.

查看更多
登录 后发表回答