本文整理汇总了Java中com.amazonaws.services.s3.AmazonS3Client.setRegion方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonS3Client.setRegion方法的具体用法?Java AmazonS3Client.setRegion怎么用?Java AmazonS3Client.setRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.AmazonS3Client
的用法示例。
在下文中一共展示了AmazonS3Client.setRegion方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AbstractS3Action
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
public AbstractS3Action( FileSystemIO delegate, Map<String, ?> env )
{
this.delegate = delegate;
AWSCredentials credentials;
try {
credentials = new ProfileCredentialsProvider().getCredentials();
}
catch( Exception ex ) {
throw new AmazonClientException( "Cannot load the credentials from the credential profiles file. "
+ "Please make sure that your credentials file is at the correct "
+ "location (~/.aws/credentials), and is in valid format.",
ex );
}
s3 = new AmazonS3Client( credentials );
Region region = Region.getRegion( Regions.EU_WEST_1 );
s3.setRegion( region );
String n = FileSystemUtils.get( env, BUCKET_READ );
if( n == null || n.trim().isEmpty() ) {
n = FileSystemUtils.get( env, BUCKET );
}
bucketName = Objects.requireNonNull( n, BUCKET + " or " + BUCKET_READ + " is not defined" );
}
示例2: getS3Client
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
public AmazonS3 getS3Client() {
if (!awsEnabled) {
throw new ResourceException(ResourceException.INTERNAL_SERVER_ERROR,
"AWS Support not enabled");
}
if (credentials == null) {
throw new ResourceException(ResourceException.INTERNAL_SERVER_ERROR,
"AWS Role credentials are not available");
}
AmazonS3Client s3 = new AmazonS3Client(credentials);
if (awsRegion != null) {
s3.setRegion(Region.getRegion(Regions.fromName(awsRegion)));
}
return s3;
}
示例3: build
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
public AmazonS3Client build() {
ClientConfiguration config = new ClientConfiguration();
if (!Util.fixNull(host).trim().isEmpty()) {
config.setProxyHost(this.host);
config.setProxyPort(this.port);
}
AmazonS3Client client = new AmazonS3Client(new DefaultAWSCredentialsProviderChain(), config);
if (!Util.fixNull(region).trim().isEmpty()) {
client.setRegion(Region.getRegion(Regions.fromName(region)));
}
return client;
}
示例4: createS3Client
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
public static AmazonS3Client createS3Client(Region region) {
Preconditions.checkNotNull(region);
AmazonS3Client s3Client = new AmazonS3Client(getCredentialProvider());
s3Client.setRegion(region);
return s3Client;
}
示例5: ContentManager
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
/**
* Constructs a content manager.
*
* @param context an Android context.
* @param identityManager identity manager to use for credentials.
* @param bucket the s3 bucket.
* @param s3DirPrefix The directory within the bucket for which this content manager will manage content.
* This may be passed as null if the root directory of the bucket should be used. The
* object delimiter is always the standard directory separator of '/'.
* @param cloudFrontDomainName The CloudFront domain name where this bucket's content may be
* retrieved by downloading over http from a CloudFront edge
* location.
* @param basePath the base path under which to store the files managed by this content
* manager. This path will have a subdirectory identifying the remote
* location, and beneath that subdirectories 'content' and 'incoming'
* will be created to store the locally cached content and incoming
* transfers respectively.
* @param clientConfiguration The client configuration for AWS clients.
*/
ContentManager(final Context context,
final IdentityManager identityManager,
final String bucket,
final String s3DirPrefix,
final String cloudFrontDomainName,
final String basePath,
final ClientConfiguration clientConfiguration) {
this.context = context.getApplicationContext();
s3Client = new AmazonS3Client(identityManager.getCredentialsProvider(), clientConfiguration);
s3Client.setRegion(Region.getRegion(AWSConfiguration.AMAZON_COGNITO_REGION));
this.bucket = bucket;
final String localDirPrefix;
if (s3DirPrefix != null && !s3DirPrefix.isEmpty()) {
if (s3DirPrefix.endsWith(DIR_DELIMITER)) {
localDirPrefix = "/" + s3DirPrefix.substring(0, s3DirPrefix.length() - 1);
this.s3DirPrefix = s3DirPrefix;
} else {
localDirPrefix = "/" + s3DirPrefix;
this.s3DirPrefix = s3DirPrefix + DIR_DELIMITER;
}
} else {
localDirPrefix = "";
this.s3DirPrefix = null;
}
final String baseContentPath = basePath + "/s3_" + bucket + localDirPrefix;
final File prefixPathFile = new File(baseContentPath);
if (!prefixPathFile.exists()) {
if (!prefixPathFile.mkdirs()) {
throw new RuntimeException(String.format(
"Can't create directory the base directory ('%s') for storing local content.",
baseContentPath));
}
}
if (!prefixPathFile.isDirectory()) {
throw new RuntimeException(
String.format("Prefix content path '%s' is not a directory.", baseContentPath));
}
localContentPath = baseContentPath + LOCAL_CONTENT_DIR_SUFFIX;
localTransferPath = baseContentPath + LOCAL_CONTENT_XFER_DIR_SUFFIX;
localContentCache = new LocalContentCache(context, "com.amazonaws.mobile.content.cache.s3."
+ bucket + localDirPrefix.replace("/", "."), localContentPath);
if (cloudFrontDomainName == null) {
transferHelper = S3TransferHelper.build(context, s3Client, bucket,
this.s3DirPrefix, localTransferPath, localContentCache);
} else {
transferHelper =
new CloudFrontTransferHelper(context, cloudFrontDomainName,
this.s3DirPrefix, localTransferPath, localContentCache);
}
}