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

Initialization


We need the AWS credentials to access Amazon Web Services for using the API tools. We will check out two ways to get an instance of com.amazonaws.auth.AWSCredentials:

  • Using BasicAWSCredentials

  • Using ProfileCredentialsProvider

Using BasicAWSCredentials

BasicAWSCredentials is a vanilla flavor implementation class for providing the AWS credentials, which are the access key and the secret key:

// Class Variable
protected AWSCredentials credentials = null;

....

public void initializeAWSCredentials(){
  credentials = new BasicAWSCredentials("ACCESS_ID", "SECRET_KEY");
}

Replace ACCESS_ID and SECRET_KEY with your actual access id and secret key.

Using ProfileCredentialsProvider

ProfileCredentialsProvider provides AWSCredentials. It accesses the configuration file and looks for the named profile credentials. This helps in storing multiple credentials in the configuration file, and in using the profile based on the name provided by the application.

The configuration file on my machine...

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