问题
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