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

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Replace bucketName with the actual bucket name and OBJECT_KEY_OR_FOLDER_NAME with either your object key or the name of the folder which is supposed to be deleted."

A block of code is set 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("================ Create Bucket ================ ");
    try {
      System.out.println("Bucket Name: " + bucketName + "\n");
      s3.createBucket(bucketName);
    } catch (AmazonServiceException exception) {
      exception.printStackTrace();
    } catch (AmazonClientException exception) {
      exception.printStackTrace();
    }
  }

  public void listBucket(){
    System.out.println("================ Listing Buckets ================ ");
    for (Bucket bucket : s3.listBuckets()) {
      System.out.println(" - " + bucket.getName());
    }
  }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

BucketVersioningConfiguration configuration = new
  BucketVersioningConfiguration(BucketVersioningConfiguration.ENABLED);

SetBucketVersioningConfigurationRequest request = new
  SetBucketVersioningConfigurationRequest(bucketName, configuration);

s3.setBucketVersioningConfiguration(request);

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click on the Create New Group button."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

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