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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.