Reputation: 635
I have code for an Android app that uses S3. I had set it up almost a year ago following this example, where, in the app dependencies, it declares:
dependencies {
compile 'com.amazonaws:aws-android-sdk-core:2.2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.+'
}
The current version at the time of writing this is 2.6.7.
Now, my problem is:
//This code came from the Mobile Hub sample application
//Obtain a reference to the mobile client. It is created in the Application class.
final AWSMobileClient awsMobileClient = AWSMobileClient.defaultMobileClient();
//Obtain a reference to the identity manager.
IdentityManager identityManager = awsMobileClient.getIdentityManager();
AmazonS3 s3Client = new AmazonS3Client(identityManager.getCredentialsProvider());
try{
//This used to return TRUE but now returns FALSE
boolean objectExists = s3Client.doesObjectExist(BUCKET_NAME, key);
...
//catch, etc.
Consequently, I am unable to download objects. I assume that this is somehow an authentication-related issue, and in following security principles is just telling me the object doesn't exist.
Nothing about the bucket name or keys has changed on either end, and I verified that the issue can be triggered and resolved by changing:
compile 'com.amazonaws:aws-android-sdk-s3:2.2.+' //works
to
compile 'com.amazonaws:aws-android-sdk-s3:2.6.7' //does not work
and rebuilding/running the app.
I'm unable to find anything in the documentation or anything about changes in versions that would cause this. Does anyone know? I've yet to see how high I can go in version without this problem occurring.
EDIT: 2.3.9 works fine, 2.4.0 is where the problem arises. I can't ascertain which of those changes could cause the issue.
Upvotes: 0
Views: 205
Reputation: 1441
If you are using version >= 2.6.0,
dependencies {
compile ('com.amazonaws:aws-android-sdk-auth-core:2.6.0@aar') { transitive = true; }
compile 'com.amazonaws:aws-android-sdk-core:2.6.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.6.0'
}
1) Create an instance of IdentityManager:
import com.amazonaws.mobile.config.AWSConfiguration;
import com.amazonaws.mobile.auth.core.IdentityManager;
IdentityManager idm = new IdentityManager(getApplicationContext(), new AWSConfiguration(getApplicationContext()));
IdentityManager.setDefaultIdentityManager(idm);
2) Use it with S3Client.
AmazonS3 s3Client = new AmazonS3Client(IdentityManager.getDefaultIdentityManager().getCredentialsProvider());
try{
//This used to return TRUE but now returns FALSE
boolean objectExists = s3Client.doesObjectExist(BUCKET_NAME, key);
...
//catch, etc.
Upvotes: 1