O'Reilly logo

Amazon S3 Essentials by Sunil Gulabani

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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-" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required