How to create a Bucket on Aws S3 using android?

Asked

Viewed 25 times

0

I’m trying to do it this way:

public AmazonS3Client getS3Client(Context context) {
        BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
        s3Client = new AmazonS3Client(credentials);
        s3Client.setRegion(Region.getRegion(Regions.US_EAST_2));

        return s3Client;

    }


public void createBucket() {
        if(amazonS3Client.doesBucketExist(bucketName)) {
            Log.e(TAG, "Já existe");
        } else {
            amazonS3Client.createBucket(bucketName);
            Log.i(TAG, "Deu certo.");
        }

    }

But I’m not sure if you need any more parameters or not. That would be the right way?

  • 1

    I wouldn’t recommend leaving your AWS credentials in a Java application, APK can be easily decompiled and your credentials will be exposed. The best way would be to call a backend safely, and the backend perform operations on the Buckets.

1 answer

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.