Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Amazon S3 Essentials

You're reading from   Amazon S3 Essentials Get started with Amazon S3 for virtually unlimited cloud and Internet storage

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher Packt
ISBN-13 9781783554898
Length 112 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Sunil Gulabani Sunil Gulabani
Author Profile Icon Sunil Gulabani
Sunil Gulabani
Arrow right icon
View More author details
Toc

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-" + new Date().getTime();

    CreateBucket object = new CreateBucket();
    object.createBucket(bucketName);
    object.listBucket();
  }

  public void createBucket(String bucketName){
    System.out.println...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime