Example usage for com.amazonaws.services.s3 AmazonS3 getObjectAsString

List of usage examples for com.amazonaws.services.s3 AmazonS3 getObjectAsString

Introduction

In this page you can find the example usage for com.amazonaws.services.s3 AmazonS3 getObjectAsString.

Prototype

String getObjectAsString(String bucketName, String key) throws AmazonServiceException, SdkClientException;

Source Link

Document

Retrieves and decodes the contents of an S3 object to a String.

Usage

From source file:net.solarnetwork.node.backup.s3.SdkS3Client.java

License:Open Source License

@Override
public String getObjectAsString(String key) throws IOException {
    AmazonS3 client = getClient();
    try {/*from   ww  w  .  ja va 2  s .co  m*/
        return client.getObjectAsString(bucketName, key);
    } catch (AmazonServiceException e) {
        log.warn("AWS error: {}; HTTP code {}; AWS code {}; type {}; request ID {}", e.getMessage(),
                e.getStatusCode(), e.getErrorCode(), e.getErrorType(), e.getRequestId());
        throw new RemoteServiceException("Error getting S3 object at " + key, e);
    } catch (AmazonClientException e) {
        log.debug("Error communicating with AWS: {}", e.getMessage());
        throw new IOException("Error communicating with AWS", e);
    }
}