Credentials set in AwsCredentials.properties file

An AmazonS3Client constructor can use a credentials file called AwsCredentials.properties, which is found on the Java classpath.

To create an S3 client that uses AwsCredentials.properties, the AmazonS3Client object is created by passing a ClasspathPropertiesFileCredentialsProvider as a constructor parameter.


Example: AwsCredentials.properties File Format

accessKey=lDrDjH0D45hQivu6FNlwQ
secretKey=bHp5DOjg0HHJrGK7h3ejEqRDnVmWZK03T4lstel6

Example: Creating an S3 Connection using AwsCredentials.properties in the Java Classpath

AWSCredentialsProvider provider = new ClasspathPropertiesFileCredentialsProvider();

AmazonS3 s3Client = new AmazonS3Client(provider);

Credentials can be put in a different file and location. The credentials can be accessed by passing the PropertiesFileCredentialsProvider constructor parameter when you create an AmazonS3Client instance.


Example: Creating an S3 Connection using a AwsCredentials.properties in another location

AWSCredentialsProvider provider = new PropertiesFileCredentialsProvider(
"/path/to/alternative/credentials/file.properties");

AmazonS3 s3Client = new AmazonS3Client(provider);