Hi I have tried to upload a dummy textfile to Amazon S3. however it doesn't work but the log generated an id. When I refresh the Amazon S3 bucket dashboard. the file hasn't been transferred.
public class AmazonService extends AsyncTask<String, Boolean, Boolean> {
Context mContext;
public AmazonService(Context context) {
mContext = context;
}
@Override
protected Boolean doInBackground(String... params) {
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
mContext,
"us-east-1:ec361bf5-52b9-477b-9a68-7e2b5f70de07", // Identity Pool ID
Regions.US_EAST_1 // Region
);
AmazonS3Client client =
new AmazonS3Client(credentialsProvider);
TransferUtility transferUtility = new TransferUtility(client, mContext);
TransferObserver observer = transferUtility.upload("elevator-app","Video/",new File("dummy.txt") );
Log.d("Test", observer.getId() + " " + observer.getBytesTransferred());
return true;
}
}
//Service that is needed to have in AndroidManifest.xml
<service android:name= "com.amazonaws.mobileconnectors.s3.transferutility.TransferService" android:enabled="true" />
I had the same problem, the reason was that I put the service tag outside the application tag. When I put the service tag inside the application tag everything worked perfectly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With