List of usage examples for com.amazonaws.services.s3 AmazonS3Client S3_SERVICE_NAME
String S3_SERVICE_NAME
To view the source code for com.amazonaws.services.s3 AmazonS3Client S3_SERVICE_NAME.
Click Source Link
From source file:com.mesosphere.dcos.cassandra.executor.backup.S3StorageDriver.java
License:Apache License
String getBucketName(BackupRestoreContext ctx) throws URISyntaxException { URI uri = new URI(ctx.getExternalLocation()); LOGGER.info("URI: " + uri); if (uri.getScheme().equals(AmazonS3Client.S3_SERVICE_NAME)) { return uri.getHost(); } else {/* w w w. j a va 2 s.com*/ return uri.getPath().split("/")[1]; } }
From source file:com.mesosphere.dcos.cassandra.executor.backup.S3StorageDriver.java
License:Apache License
String getPrefixKey(BackupRestoreContext ctx) throws URISyntaxException { URI uri = new URI(ctx.getExternalLocation()); String[] segments = uri.getPath().split("/"); int startIndex = uri.getScheme().equals(AmazonS3Client.S3_SERVICE_NAME) ? 1 : 2; String prefixKey = ""; for (int i = startIndex; i < segments.length; i++) { prefixKey += segments[i];/*from ww w .j av a 2s . c o m*/ if (i < segments.length - 1) { prefixKey += "/"; } } prefixKey = (prefixKey.length() > 0 && !prefixKey.endsWith("/")) ? prefixKey + "/" : prefixKey; prefixKey += ctx.getName(); // append backup name return prefixKey; }
From source file:com.mesosphere.dcos.cassandra.executor.backup.S3StorageDriver.java
License:Apache License
String getEndpoint(BackupRestoreContext ctx) throws URISyntaxException { URI uri = new URI(ctx.getExternalLocation()); String scheme = uri.getScheme(); if (scheme.equals(AmazonS3Client.S3_SERVICE_NAME)) { return Constants.S3_HOSTNAME; } else {//from w w w. j av a2s .co m String endpoint = scheme + "://" + uri.getHost(); int port = uri.getPort(); if (port != -1) { endpoint += ":" + Integer.toString(port); } return endpoint; } }
From source file:org.ow2.proactive.scheduler.examples.S3ConnectorUtils.java
License:Open Source License
/** * Get or initialize the S3 client./*from w w w . jav a 2 s . c o m*/ * Note: this method must be synchronized because we're accessing the * field and we're calling this method from a worker thread. * * @return the S3 client */ protected static synchronized AmazonS3 getS3Client(String accessKey, String secretKey, String... args) { BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider(credentials)); if (args.length == 1) { builder = builder.withRegion(args[0]); } else { String endpoint = args[0] + "://" + args[1]; String clientRegion = null; if (!ServiceUtils.isS3USStandardEndpoint(endpoint) && (clientRegion = AwsHostNameUtils .parseRegion(args[1], AmazonS3Client.S3_SERVICE_NAME)) == null) { throw new IllegalArgumentException("Invalid region in " + args[1]); } builder = builder .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, clientRegion)); } builder = builder.withPathStyleAccessEnabled(true); return builder.build(); }
From source file:org.springframework.cloud.aws.core.io.s3.SimpleStorageResource.java
License:Apache License
@Override public URL getURL() throws IOException { if (this.amazonS3 instanceof AmazonS3Client) { Region region = ((AmazonS3Client) this.amazonS3).getRegion().toAWSRegion(); return new URL("https", region.getServiceEndpoint(AmazonS3Client.S3_SERVICE_NAME), "/" + this.bucketName + "/" + this.objectName); } else {//ww w .j av a 2s . co m return super.getURL(); } }