aws android sdk core,amazon s3 – AWS S3 Android SDK 2.11.0 – Stack Overflow

  • Post author:
  • Post category:其他

My code looks like this:

final AmazonS3Client s3Client = new AmazonS3Client(new BasicAWSCredentials(s3AccessKeyId, s3SecretAccessKey));

final TransferUtility util = TransferUtility.

builder().s3Client(s3Client).context(context).build();

When upgrading from ‘com.amazonaws:aws-android-sdk-s3:2.7.5’ to ‘com.amazonaws:aws-android-sdk-s3:2.11.0’ I get the following error in my logcat, even though the upload is still working:

E/nsferNetworkLossHandler: TransferNetworkLossHandler is not created. Please call `TransferNetworkLossHandler.getInstance(Context)` to instantiate it before retrieving

E/UploadTask: TransferUtilityException: [com.amazonaws.mobileconnectors.s3.transferutility.TransferUtilityException: TransferNetworkLossHandler is not created. Please call `TransferNetworkLossHandler.getInstance(Context)` to instantiate it before retrieving]

When I change my code to include the TransferNetworkLossHandler:

TransferNetworkLossHandler.getInstance(context);

final AmazonS3Client s3Client = new AmazonS3Client(new BasicAWSCredentials(s3AccessKeyId, s3SecretAccessKey));

final TransferUtility util = TransferUtility.

builder().s3Client(s3Client).context(context).build();

without doing anything with it, I get no more error.

However, this is not how this error message is intended. It tells you to use the TransferNetworkLossHandler, but there is no documentation on how to use it.

I just want to display an error (like a Toast or an AlertDialog) to the user, if the upload did not work. So I don’t need the handler at all. But I also don’t want the error message to be written into my log everytime. Also I don’t want to use this hackish solution of just grabbing an instance and not doing anything with it.

What is the proper use of this handler for my case?