Bucket

Now we will see the implementation part. (For the basics on bucket, please refer to Chapter 1, Know-How about S3, and Chapter 2, S3 using the AWS Management Console.)

Creating a bucket

AmazonS3Client has a method to create a bucket, which is named s3.createBucket(bucketName);.

In this method, bucketName is the name of your defined bucket.

The complete code for the CreateBucket method is as follows:

package com.chapter3; import java.util.Date; import com.amazonaws.AmazonClientException; import com.amazonaws.AmazonServiceException; import com.amazonaws.services.s3.model.Bucket; public class CreateBucket extends AmazonS3ClientInitializer{ public CreateBucket() { super(); } public static void main(String[] args) { String bucketName = "sg-bucket-2015-using-java-api-" ...

Get Amazon S3 Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.