Java Code Examples for com.amazonaws.services.s3.AmazonS3Client#doesBucketExist()

The following examples show how to use com.amazonaws.services.s3.AmazonS3Client#doesBucketExist() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: S3FileStoreIntegrationTest.java    From Cheddar with Apache License 2.0 5 votes vote down vote up
@Before
public void before() {
    amazonS3Client = new AmazonS3Client();

    // create bucket if not present
    final String fullBucketName = BUCKET_SCHEMA + "-" + BUCKET_NAME;
    if (!amazonS3Client.doesBucketExist(fullBucketName)) {
        amazonS3Client.createBucket(fullBucketName);
    }
}
 
Example 2
Source File: S3Utils.java    From amazon-kinesis-connectors with Apache License 2.0 2 votes vote down vote up
/**
 * 
 * @param client
 *        The {@link AmazonS3Client} with read permissions
 * @param bucketName
 *        Check if this bucket exists
 * @return true if the Amazon S3 bucket exists, otherwise return false
 */
private static boolean bucketExists(AmazonS3Client client, String bucketName) {
    return client.doesBucketExist(bucketName);
}