Example usage for com.amazonaws.services.s3.model ListObjectsRequest setRequestCredentials

List of usage examples for com.amazonaws.services.s3.model ListObjectsRequest setRequestCredentials

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.model ListObjectsRequest setRequestCredentials.

Prototype

@Deprecated
public void setRequestCredentials(AWSCredentials credentials) 

Source Link

Document

Sets the optional credentials to use for this request, overriding the default credentials set at the client level.

Usage

From source file:org.entando.entando.plugins.jps3awsclient.aps.system.services.storage.AmazonS3StorageManager.java

License:Open Source License

public ObjectListing getS3Objects(String prefix) throws ApsSystemException {
    if (!this.isActive()) {
        return null;
    }/*from  w  w  w.  j  a va 2s. c o  m*/
    if (prefix == null || prefix.trim().length() == 0) {
        return null;
    }
    try {
        String key = prefix;
        if (!key.endsWith("/")) {
            key += "/";
        }
        ListObjectsRequest lor = new ListObjectsRequest();
        lor.setBucketName(this.getBucketName());
        lor.setPrefix(key);
        lor.setDelimiter("/");
        AWSCredentials creds = new BasicAWSCredentials(this.getCredentialKey(), this.getCredentialSecret());
        lor.setRequestCredentials(creds);
        lor.setPrefix(key);
        return this.getS3Client().listObjects(lor);
    } catch (Throwable t) {
        _logger.error("error in getS3Objects", t);
        throw new ApsSystemException("Error", t);
    }
}