@Override public AmazonS3 apply(AmazonS3ClientParamsWrapper params) { return new AmazonS3Client(params); } };
/** * 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; }
/** * Constructs a new <code>TransferManager</code> and Amazon S3 client using * the specified AWS security credentials provider. * <p> * <code>TransferManager</code> and client objects may pool connections and * threads. Reuse <code>TransferManager</code> and client objects and share * them throughout applications. * <p> * TransferManager and all AWS client objects are thread safe. * * @param credentialsProvider * The AWS security credentials provider to use when making * authenticated requests. * @deprecated use {@link TransferManagerBuilder#withS3Client(AmazonS3)} for example: * {@code TransferManagerBuilder.standard().withS3Client(AmazonS3ClientBuilder.standard.withCredentials(credentialsProvider).build()).build(); } */ @Deprecated public TransferManager(AWSCredentialsProvider credentialsProvider) { this(new AmazonS3Client(credentialsProvider)); }
/** * Constructs a new <code>TransferManager</code> and Amazon S3 client using * the specified AWS security credentials. * <p> * <code>TransferManager</code> and client objects * may pool connections and threads. * Reuse <code>TransferManager</code> and client objects * and share them throughout applications. * <p> * TransferManager and all AWS client objects are thread safe. * * @param credentials * The AWS security credentials to use when making authenticated * requests. * @deprecated use {@link TransferManagerBuilder#withS3Client(AmazonS3)} for example: * {@code TransferManagerBuilder.standard().withS3Client(AmazonS3ClientBuilder.standard.withCredentials(credentials).build()).build(); } */ @Deprecated public TransferManager(AWSCredentials credentials) { this(new AmazonS3Client(credentials)); }
public ClusterGraphService(String s3CredentialsFilename, Boolean workOffline, String bucket) { if(!workOffline) { if (s3CredentialsFilename != null) { AWSCredentials creds = new ProfileCredentialsProvider(s3CredentialsFilename, "default").getCredentials(); s3 = new AmazonS3Client(creds); } else { // This will first check for credentials in environment variables or ~/.aws/credentials // then fall back on S3 credentials propagated to EC2 instances via IAM roles. s3 = new AmazonS3Client(); } this.graphBucket = bucket; } this.workOffline = workOffline; }
/** * Constructs a new <code>TransferManager</code> and Amazon S3 client using * the credentials from <code>DefaultAWSCredentialsProviderChain</code> * <p> * <code>TransferManager</code> and client objects may pool connections and * threads. Reuse <code>TransferManager</code> and client objects and share * them throughout applications. * <p> * TransferManager and all AWS client objects are thread safe. * @deprecated use {@link TransferManagerBuilder#defaultTransferManager()} */ @Deprecated public TransferManager(){ this(new AmazonS3Client(new DefaultAWSCredentialsProviderChain())); }
BufferedImage image = ... ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(image, "png", os); byte[] buffer = os.toByteArray(); InputStream is = new ByteArrayInputStream(buffer); AmazonS3 s3 = new AmazonS3Client(new PropertiesCredentials(cred)); ObjectMetadata meta = new ObjectMetadata(); meta.setContentLength(buffer.length); s3.putObject(new PutObjectRequest("folder", key, is, meta));
localClient = new AmazonS3Client(awsCredentialProvider, clientConfig.getAWSClientConfig()); localClient = new AmazonS3Client(awsCredentialProvider); localClient = new AmazonS3Client(basicAWSCredentials, clientConfig.getAWSClientConfig()); localClient = new AmazonS3Client(basicAWSCredentials); localClient = new AmazonS3Client(clientConfig.getAWSClientConfig()); localClient = new AmazonS3Client();
/** * Returns a new client with region configured to * region. * Also updates the clientsByRegion map by associating the * new client with region. * * @param region * The region the returned {@link AmazonS3} will be * configured to use. * @return A new {@link AmazonS3} client with region set to region. */ private AmazonS3 cacheClient(String region) { if (awscredentialsProvider == null) { throw new IllegalArgumentException("No credentials provider found to connect to S3"); } AmazonS3 client = new AmazonS3Client(awscredentialsProvider); client.setRegion(RegionUtils.getRegion(region)); clientsByRegion.put(region, client); return client; }
public PointSetDatastore(Integer maxCacheSize, String s3CredentialsFilename, Boolean workOffline, String pointsetBucket){ super(); // allow the data store to work offline with cached data and skip S3 connection this.workOffline = workOffline; this.pointsetBucket = pointsetBucket; if(!this.workOffline) { if (s3CredentialsFilename != null) { AWSCredentials creds = new ProfileCredentialsProvider(s3CredentialsFilename, "default").getCredentials(); s3 = new AmazonS3Client(creds); } else { // default credentials providers, e.g. IAM role s3 = new AmazonS3Client(); } } // set up the cache this.pointSets = CacheBuilder.newBuilder() .maximumSize(maxCacheSize) .build(new S3PointSetLoader(workOffline, s3, pointsetBucket)); }
public static AmazonS3 getClient() { if( _s3 == null ) { synchronized( _lock ) { if( _s3 == null ) { try { _s3 = new AmazonS3Client(new H2OAWSCredentialsProviderChain(), s3ClientCfg()); } catch( Throwable e ) { StringBuilder msg = new StringBuilder(); msg.append(e.getMessage() + "\n"); msg.append("Unable to load S3 credentials."); if( H2O.OPT_ARGS.aws_credentials == null ) msg.append(HELP); throw Log.err(new RuntimeException(msg.toString())); } } } } return _s3; }
@Override public AmazonS3 get() { AmazonS3Client amazonS3 = new AmazonS3Client(awsClusterSecurityManager.getCredentialsProvider()); amazonS3.setRegion(region); return amazonS3; } });
AmazonS3 s3 = new AmazonS3Client(); // provide credentials, if need be ObjectListing objectListing = s3.listObjects(new ListObjectsRequest() .withBucketName("cdn.generalsentiment.com"); for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { System.out.println(objectSummary.getKey()); }
s3 = new AmazonS3Client(); s3.setRegion(awsRegion);
private AmazonS3 getS3Client() throws Exception{ this.bucketName = properties.getProperty( "usergrid.binary.bucketname" ); if(bucketName == null){ logger.error( "usergrid.binary.bucketname not properly set so amazon bucket is null" ); throw new AwsPropertiesNotFoundException( "usergrid.binary.bucketname" ); } final UsergridAwsCredentialsProvider ugProvider = new UsergridAwsCredentialsProvider(); AWSCredentials credentials = ugProvider.getCredentials(); ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setProtocol(Protocol.HTTP); s3Client = new AmazonS3Client(credentials, clientConfig); if(regionName != null) s3Client.setRegion( Region.getRegion(Regions.fromName(regionName)) ); return s3Client; }
/** * Create client using credentials provider. This is the preferred way for creating clients */ @Override protected AmazonS3Client createClient(final ProcessContext context, final AWSCredentialsProvider credentialsProvider, final ClientConfiguration config) { getLogger().info("Creating client with credentials provider"); initializeSignerOverride(context, config); final AmazonS3Client s3 = new AmazonS3Client(credentialsProvider, config); initalizeEndpointOverride(context, s3); return s3; }
/** * Create client using AWSCredentials * * @deprecated use {@link #createClient(ProcessContext, AWSCredentialsProvider, ClientConfiguration)} instead */ @Override protected AmazonS3Client createClient(final ProcessContext context, final AWSCredentials credentials, final ClientConfiguration config) { getLogger().info("Creating client with AWS credentials"); initializeSignerOverride(context, config); final AmazonS3Client s3 = new AmazonS3Client(credentials, config); initalizeEndpointOverride(context, s3); return s3; }
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); }
client = new AmazonS3Client(provider, clientConfiguration);
AmazonS3Client amazonS3Client = new AmazonS3Client(credentials, clientConf);