本文整理了Java中com.amazonaws.services.s3.model.Region.getFirstRegionId
方法的一些代码示例,展示了Region.getFirstRegionId
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Region.getFirstRegionId
方法的具体详情如下:
包路径:com.amazonaws.services.s3.model.Region
类名称:Region
方法名:getFirstRegionId
[英]Returns the first region id or null for #US_Standard.
[中]返回#US_标准的第一个区域id或null。
代码示例来源:origin: aws/aws-sdk-java
private static String convertRegionToString(Region region, String bucketName) {
String regionAsString;
if (region == null) {
if (BucketNameUtils.isDNSBucketName(bucketName)) {
regionAsString = Region.US_Standard.getFirstRegionId();
} else {
throw new IllegalArgumentException("Region must be specified for bucket that cannot be addressed using virtual host style");
}
} else {
regionAsString = region.getFirstRegionId();
}
return regionAsString;
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Returns the respective AWS region.
*/
public com.amazonaws.regions.Region toAWSRegion() {
String s3regionId = getFirstRegionId();
if ( s3regionId == null ) { // US Standard
// TODO This is a bit of a hack but customers are relying on this returning us-east-1 rather then
// aws-global. For now we'll keep the legacy behavior and consider changing it in the next major version
// bump. See TT0073140598
return RegionUtils.getRegion("us-east-1");
} else {
return RegionUtils.getRegion(s3regionId);
}
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* Constructs a new {@link ID} with all the required parameters.
*
* @param bucket The name of the bucket containing the desired object.
* @param key The key in the specified bucket under which the object is
* stored.
*/
ID(Region region, String bucket, String key) {
if (region == null) {
if (BucketNameUtils.isDNSBucketName(bucket)) {
this.regionId = Region.US_Standard.getFirstRegionId();
} else {
throw new IllegalArgumentException(
"Region must be specified for bucket that cannot be addressed using virtual host style");
}
} else {
this.regionId = region.getFirstRegionId();
}
this.bucket = bucket;
this.key = key;
}
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* Returns the respective AWS region.
*/
public com.amazonaws.regions.Region toAWSRegion() {
final String s3regionId = getFirstRegionId();
if (s3regionId == null) { // US Standard
return RegionUtils.getRegionByEndpoint(Constants.S3_HOSTNAME);
} else {
return RegionUtils.getRegion(s3regionId);
}
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testDefaultRegion() throws IOException {
S3Link.ID id = new S3Link.ID("bucketname", "keyname");
assertEquals(Region.US_Standard.getFirstRegionId(), id.getRegionId());
String json = id.toJson();
S3Link.ID twin = S3Link.ID.fromJson(json);
assertEquals("bucketname", twin.getBucket());
assertEquals("keyname", twin.getKey());
assertEquals(Region.US_Standard.getFirstRegionId(), twin.getRegionId());
}
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-dynamodb
private static String convertRegionToString(Region region, String bucketName) {
String regionAsString;
if (region == null) {
if (BucketNameUtils.isDNSBucketName(bucketName)) {
regionAsString = Region.US_Standard.getFirstRegionId();
} else {
throw new IllegalArgumentException("Region must be specified for bucket that cannot be addressed using virtual host style");
}
} else {
regionAsString = region.getFirstRegionId();
}
return regionAsString;
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testFromJason() {
String json = "{\"s3\":{\"region\":\"ap-southeast-2\",\"bucket\":\"test-bucket\",\"key\":\"testKey\"}}";
S3Link s3link = S3Link.fromJson(mapper.getS3ClientCache(), json);
assertEquals("test-bucket", s3link.getBucketName());
assertEquals("ap-southeast-2", s3link.getS3Region().getFirstRegionId());
assertEquals("testKey", s3link.getKey());
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testToFromJson() throws IOException {
S3Link.ID id = new S3Link.ID(Region.AP_Tokyo, "bucket", "key");
String json = id.toJson();
S3Link.ID twin = S3Link.ID.fromJson(json);
assertEquals("bucket", twin.getBucket());
assertEquals("key", twin.getKey());
assertEquals(Region.AP_Tokyo.getFirstRegionId(), twin.getRegionId());
}
代码示例来源:origin: com.amazonaws/aws-android-sdk-s3
/**
* Returns the respective AWS region.
*/
public com.amazonaws.regions.Region toAWSRegion() {
final String s3regionId = getFirstRegionId();
if (s3regionId == null) { // US Standard
return RegionUtils.getRegionByEndpoint(Constants.S3_HOSTNAME);
} else {
return RegionUtils.getRegion(s3regionId);
}
}
}
代码示例来源:origin: Nextdoor/bender
/**
* Returns the respective AWS region.
*/
public com.amazonaws.regions.Region toAWSRegion() {
String s3regionId = getFirstRegionId();
if ( s3regionId == null ) { // US Standard
// TODO This is a bit of a hack but customers are relying on this returning us-east-1 rather then
// aws-global. For now we'll keep the legacy behavior and consider changing it in the next major version
// bump. See TT0073140598
return RegionUtils.getRegion("us-east-1");
} else {
return RegionUtils.getRegion(s3regionId);
}
}
}
代码示例来源:origin: com.hotels/circus-train-s3-s3-copier
private AmazonS3 newGlobalInstance(S3S3CopierOptions s3s3CopierOptions) {
HadoopAWSCredentialProviderChain credentialsChain = getCredentialsProviderChain();
AmazonS3ClientBuilder builder = AmazonS3ClientBuilder
.standard()
.withForceGlobalBucketAccessEnabled(Boolean.TRUE)
.withCredentials(credentialsChain);
URI s3Endpoint = s3s3CopierOptions.getS3Endpoint();
if (s3Endpoint != null) {
EndpointConfiguration endpointConfiguration = new EndpointConfiguration(s3Endpoint.toString(),
Region.US_Standard.getFirstRegionId());
builder.withEndpointConfiguration(endpointConfiguration);
}
return builder.build();
}
代码示例来源:origin: HotelsDotCom/circus-train
private AmazonS3 newGlobalInstance(S3S3CopierOptions s3s3CopierOptions) {
HadoopAWSCredentialProviderChain credentialsChain = getCredentialsProviderChain();
AmazonS3ClientBuilder builder = AmazonS3ClientBuilder
.standard()
.withForceGlobalBucketAccessEnabled(Boolean.TRUE)
.withCredentials(credentialsChain);
URI s3Endpoint = s3s3CopierOptions.getS3Endpoint();
if (s3Endpoint != null) {
EndpointConfiguration endpointConfiguration = new EndpointConfiguration(s3Endpoint.toString(),
Region.US_Standard.getFirstRegionId());
builder.withEndpointConfiguration(endpointConfiguration);
}
return builder.build();
}
内容来源于网络,如有侵权,请联系作者删除!