private void init() { // calling this.setEndpoint(...) will also modify the signer accordingly setEndpoint(Constants.S3_HOSTNAME); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain( "/com/amazonaws/services/s3/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain( "/com/amazonaws/services/s3/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); }
s3Client.setEndpoint(endPoint); System.out.println("Connection successfully initialized"); } catch (Exception e){
/** * Instantiates {@code AmazonS3Client} instance. * * @return Client instance to use to connect to AWS. */ AmazonS3Client createAmazonS3Client() { AmazonS3Client cln = cfg != null ? (cred != null ? new AmazonS3Client(cred, cfg) : new AmazonS3Client(credProvider, cfg)) : (cred != null ? new AmazonS3Client(cred) : new AmazonS3Client(credProvider)); if (!F.isEmpty(bucketEndpoint)) cln.setEndpoint(bucketEndpoint); return cln; }
localClient.setEndpoint(endpoint); log.info("Setting S3 endpoint to: " + endpoint);
amazonS3Client.setEndpoint(conf.get(PropertyKey.UNDERFS_S3_ENDPOINT));
private void init() { // calling this.setEndpoint(...) will also modify the signer accordingly setEndpoint(Constants.S3_HOSTNAME); this.endpointPrefix = "s3"; final HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain( "/com/amazonaws/services/s3/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain( "/com/amazonaws/services/s3/request.handler2s")); }
@Test(expected = IllegalStateException.class) public void testSetEndpointAccelerate() { s3.setEndpoint(Constants.S3_ACCELERATE_HOSTNAME); }
@Test public void testSetEndpoint() { final String region = "us-west-2"; s3.setEndpoint(String.format("s3-%s.amazonaws.com", region)); assertEquals(region, s3.clientRegion); s3.setEndpoint(String.format("s3.%s.amazonaws.com", region)); assertEquals(region, s3.clientRegion); }
/** * Tests the behavior when using S3 standard endpoint with explicit region. */ @Test public void testStandardEndpointWithRegionOverride() { final AmazonS3Client s3 = new AmazonS3Client(); // Explicitly setting a regionName, now it defaults to sigv2, but sigv4 // is allowed to be turned on by enforceV4. s3.setEndpoint("s3.amazonaws.com", "s3", "us-west-1"); // Default to SigV2 assertSigV4WithRegion(s3, "us-west-1"); // "Enforce" v4 signing should work. System.setProperty("com.amazonaws.services.s3.enforceV4", "true"); assertSigV4WithRegion(s3, "us-west-1"); s3.setEndpoint("s3.amazonaws.com", "s3", "eu-west-1"); assertSigV4WithRegion(s3, "eu-west-1"); }
/** * Tests that BJS endpoint always defaults to SigV4. */ @Test public void testBJSDefaultSigning() { final AmazonS3Client s3 = new AmazonS3Client(); s3.setEndpoint("s3.cn-north-1.amazonaws.com.cn"); assertSigV4WithRegion(s3, "cn-north-1"); // Using any of the system props should not affect the default System.setProperty("com.amazonaws.services.s3.enforceV4", "true"); assertSigV4WithRegion(s3, "cn-north-1"); System.setProperty("com.amazonaws.services.s3.enableV4", "true"); assertSigV4WithRegion(s3, "cn-north-1"); }
private void testSigV4WithRegionDefaultSigning(String endpoint, String expectedRegionName) { clearFlags(); final AmazonS3Client s3 = new AmazonS3Client(); s3.setEndpoint(endpoint); assertSigV4WithRegion(s3, expectedRegionName); // Enforce SigV4 should change the default System.setProperty("com.amazonaws.services.s3.enforceV4", "true"); assertSigV4WithRegion(s3, expectedRegionName); clearFlags(); // Enable SigV4 should also work System.setProperty("com.amazonaws.services.s3.enableV4", "true"); assertSigV4WithRegion(s3, expectedRegionName); }
LOGGER.debug(format("Setting the end point for S3 client with access key %1$s to %2$s.", clientOptions.getAccessKey(), clientOptions.getEndPoint())); client.setEndpoint(clientOptions.getEndPoint());
public S3BulkEventStore(Metastore metastore, AWSConfig config, FieldDependencyBuilder.FieldDependency fieldDependency) { this.metastore = metastore; this.config = config; this.s3Client = new AmazonS3Client(config.getCredentials()); s3Client.setRegion(config.getAWSRegion()); if (config.getS3Endpoint() != null) { s3Client.setEndpoint(config.getS3Endpoint()); } kinesis = new AmazonKinesisClient(config.getCredentials()); kinesis.setRegion(config.getAWSRegion()); if (config.getKinesisEndpoint() != null) { kinesis.setEndpoint(config.getKinesisEndpoint()); } cloudWatchClient = new AmazonCloudWatchAsyncClient(config.getCredentials()); cloudWatchClient.setRegion(config.getAWSRegion()); this.conditionalMagicFieldsSize = fieldDependency.dependentFields.size(); }
private void init() { // calling this.setEndpoint(...) will also modify the signer accordingly setEndpoint(Constants.S3_HOSTNAME); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain( "/com/amazonaws/services/s3/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain( "/com/amazonaws/services/s3/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); }
public S3Emitter(KinesisConnectorConfiguration configuration) { s3Bucket = configuration.S3_BUCKET; s3Endpoint = configuration.S3_ENDPOINT; s3client = new AmazonS3Client(configuration.AWS_CREDENTIALS_PROVIDER); if (s3Endpoint != null) { s3client.setEndpoint(s3Endpoint); } }
public ThreddsS3ClientImpl() { // Use HTTP; it's much faster. this.s3Client = new AmazonS3Client(); this.s3Client.setEndpoint("http://s3.amazonaws.com"); }
public S3Emitter(KinesisConnectorConfiguration configuration) { s3Bucket = configuration.S3_BUCKET; s3Endpoint = configuration.S3_ENDPOINT; s3client = new AmazonS3Client(configuration.AWS_CREDENTIALS_PROVIDER); if (s3Endpoint != null) { s3client.setEndpoint(s3Endpoint); } }
BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials( ACCESS_KEY, SECRET_KEY ); AmazonS3Client s3Client = new AmazonS3Client(basicAWSCredentials); s3Client.setEndpoint(ENDPOINT); s3Client.setRegion(Region.getRegion(Regions.EU_WEST_1));; PutObjectRequest por = new PutObjectRequest( "YOUR_BUCKET_NAME", "YOUR_KEY", file); } s3Client.putObject(por);
public S3MockClientFactory(int port, String username, String pass) { try { this.s3.start(port, username, pass); } catch (IOException | InterruptedException | InvalidExitValueException | TimeoutException e) { throw new RuntimeException(e); } BasicAWSCredentials awsCredentials = new BasicAWSCredentials(username, pass); this.client = new AmazonS3Client(awsCredentials, new ClientConfiguration()); this.client.setEndpoint("http://127.0.0.1:" + port); this.client.createBucket(S3_BUCKET); }
S3Mock api = S3Mock.create(8001, "/tmp/s3"); api.start(); AmazonS3Client client = new AmazonS3Client(new AnonymousAWSCredentials()); // use local API mock, not the AWS one client.setEndpoint("http://127.0.0.1:8001"); client.createBucket("testbucket"); client.putObject("testbucket", "file/name", "contents");