public URL getPreSignedUrl(long attachmentId, HttpMethod method, boolean unaccelerated) { AmazonS3 client = new AmazonS3Client(credentials); GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, String.valueOf(attachmentId), method); request.setExpiration(new Date(System.currentTimeMillis() + DURATION)); request.setContentType("application/octet-stream"); if (unaccelerated) { client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build()); } else { client.setS3ClientOptions(S3ClientOptions.builder().setAccelerateModeEnabled(true).build()); } return client.generatePresignedUrl(request); }
S3ClientOptions clientOptions = new S3ClientOptions(); clientOptions.setPathStyleAccess(true); client.setS3ClientOptions(clientOptions);
AmazonS3 s3Client= new AmazonS3Client(credentials); s3Client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build());
@Override public void setS3ClientOptions(S3ClientOptions clientOptions) { getDelegate().setS3ClientOptions(clientOptions); }
AmazonS3 client = new AmazonS3Client(credentials); client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));
/** * Enables path-style access to S3 buckets if configured. By default, the * behavior is to use virtual hosted-style access with URIs of the form * http://bucketname.s3.amazonaws.com. Enabling path-style access and a * region-specific endpoint switches the behavior to use URIs of the form * http://s3-eu-west-1.amazonaws.com/bucketname. * * @param s3 S3 client * @param conf Hadoop configuration */ private static void enablePathStyleAccessIfRequired(AmazonS3 s3, Configuration conf) { final boolean pathStyleAccess = conf.getBoolean(S3Constants.PATH_STYLE_ACCESS, false); if (pathStyleAccess) { logger.debug("Enabling path style access!"); s3.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true)); } }
public static AmazonS3 s3client(Map<String, String> config) { // Use default credentials provider that looks in Env + Java properties + profile + instance role AmazonS3 s3Client = new AmazonS3Client(); // If worker config sets explicit endpoint override (e.g. for testing) use that String s3Endpoint = config.get("s3.endpoint"); if (s3Endpoint != null && !Objects.equals(s3Endpoint, "")) { s3Client.setEndpoint(s3Endpoint); } Boolean s3PathStyle = Boolean.parseBoolean(config.get("s3.path_style")); if (s3PathStyle) { s3Client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true)); } return s3Client; }
s3.setS3ClientOptions(clientOptions); String endpoint = this.endpoint; if (!endpoint.endsWith("/")) {
/** * Build a new Amazon S3 instance with the URI and the properties provided * @param uri URI mandatory * @param props Properties with the credentials and others options * @return AmazonS3 */ public AmazonS3 getAmazonS3(URI uri, Properties props) { AmazonS3 client = createAmazonS3(getCredentialsProvider(props), getClientConfiguration(props), getRequestMetricsCollector(props)); if (uri.getHost() != null) { if (uri.getPort() != -1) client.setEndpoint(uri.getHost() + ':' + uri.getPort()); else client.setEndpoint(uri.getHost()); } client.setS3ClientOptions(getClientOptions(props)); return client; }
if (pathStyleAccess) { LOG.debug("Enabling path style access!"); s3.setS3ClientOptions(S3ClientOptions.builder() .setPathStyleAccess(true) .build());
s3Service.setS3ClientOptions(S3ClientOptions.builder().disableChunkedEncoding() .setPathStyleAccess(Boolean.parseBoolean(props.getProperty("disableDNSBucket"))).build()); s3Service.setS3ClientOptions(S3ClientOptions.builder() .setAccelerateModeEnabled(Boolean.parseBoolean(props.getProperty("use-accelerated-mode"))) .build());
s3.setS3ClientOptions(clientOptions); String endpoint = prop.getProperty(s3Alias + ".s3.endpoint"); if (!endpoint.endsWith("/")) {
public AmazonS3 getS3client() { BasicAWSCredentials awsCreds = new BasicAWSCredentials(accessKey, securityKey); if (testing && (!testingUrl.isEmpty() || !testingUrl.equals(""))) { s3client = new AmazonS3Client(awsCreds); s3client.setRegion(Region.getRegion(Regions.fromName(bucketRegion))); s3client.setEndpoint(testingUrl); s3client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).disableChunkedEncoding().build()); } else { s3client = AmazonS3ClientBuilder.standard().withRegion(Regions.fromName(bucketRegion)) .withCredentials(new AWSStaticCredentialsProvider(awsCreds)).build(); } return s3client; }
mClient.setEndpoint(serviceUrl); mClient.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build());
mClient.setEndpoint(serviceUrl); mClient.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build());
@Override public void start(Map<String, String> props) throws ConnectException { readConfig(props); // Use default credentials provider that looks in Env + Java properties + profile + instance role AmazonS3 s3Client = new AmazonS3Client(); // If worker config sets explicit endpoint override (e.g. for testing) use that if (overrideS3Endpoint != "") { s3Client.setEndpoint(overrideS3Endpoint); } if (s3PathStyle) { s3Client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true)); } s3 = new S3Writer(bucket, prefix, s3Client); // Recover initial assignments Set<TopicPartition> assignment = context.assignment(); recoverAssignment(assignment); }
s3.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build());