· 8 years ago · Dec 12, 2017, 09:38 AM
1s3 = boto3.resource(
2 's3',
3 endpoint_url='https://my.non-amazon-endpoint.com',
4 aws_access_key_id=access_key,
5 aws_secret_access_key=secret_key
6)
7
8bucket = s3.create_bucket(Bucket="my-bucket") # successfully creates bucket
9
10BasicAWSCredentials awsCreds = new BasicAWSCredentials(access_key, secret_key);
11
12AwsClientBuilder.EndpointConfiguration config =
13 new AwsClientBuilder.EndpointConfiguration(
14 "https://my.non-amazon-endpoint.com",
15 "MyRegion");
16
17AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
18 .withEndpointConfiguration(config)
19 .build();
20
21List<Bucket> buckets = s3Client.listBuckets();
22// this works and lists all containers, hence the connection should be fine
23for (Bucket bucket : buckets) {
24 System.out.println(bucket.getName() + "t" +
25 StringUtils.fromDate(bucket.getCreationDate()));
26}
27
28Bucket bucket = s3Client.createBucket("my-bucket");
29// AmazonS3Exception: The specified location-constraint is not valid (Service: Amazon S3; Status Code: 400; Error Code: InvalidLocationConstraint...