I am trying to upload a file (JPEG) using the upload service in my ACL enabled Android app.
The problem is I keep on getting java.io.IOException: No Authentication Challenges Found, thus indicating some sort of authentication issues with my app.
But I am authenticating the user in the onCreate() method itself and then I call the method to upload the file.
Also if I use uploadFileForUser() method, file gets uploaded successfully. And if I upload file in my ACL disabled app, file gets uploaded without any issues.
So there has to be something that I am missing for sure. Please someone share it if you have any idea of what's going on.
This is the code I wrote:
//For Authentication:
final UserService userService = App42API.buildUserService();
userService.getUser("Sagar Sheokand", new App42CallBack() {
@Override
public void onSuccess(Object arg0) {
userService.authenticate("Sagar Sheokand", "Sagar", new App42CallBack() {
@Override
public void onSuccess(Object arg0) {
User user = (User)arg0;
System.out.println("User: Sagar Sheokand Authenticated");
userService.setSessionId(user.getSessionId());
fileUpload();
}
@Override
public void onException(Exception arg0) {
System.out.println("---User Sagar Sheokand not Authenticated---");
}
});
// For File Upload:
final UploadService uploadService = App42API.buildUploadService();
uploadService.uploadFile(s, path, UploadFileType.IMAGE, "photo", new App42CallBack() {
@Override
public void onSuccess(Object arg0) {
// TODO Auto-generated method stub
//arg0.toString();
}
@Override
public void onException(Exception arg0) {
// TODO Auto-generated method stub
arg0.printStackTrace();
}
});