Java Code Examples for com.amazonaws.services.s3.AmazonS3Client#setRegion()
The following examples show how to use
com.amazonaws.services.s3.AmazonS3Client#setRegion() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractS3CacheBolt.java From storm-crawler with Apache License 2.0 | 6 votes |
/** Returns an S3 client given the configuration **/ public static AmazonS3Client getS3Client(Map conf) { AWSCredentialsProvider provider = new DefaultAWSCredentialsProviderChain(); AWSCredentials credentials = provider.getCredentials(); ClientConfiguration config = new ClientConfiguration(); AmazonS3Client client = new AmazonS3Client(credentials, config); String regionName = ConfUtils.getString(conf, REGION); if (StringUtils.isNotBlank(regionName)) { client.setRegion(RegionUtils.getRegion(regionName)); } String endpoint = ConfUtils.getString(conf, ENDPOINT); if (StringUtils.isNotBlank(endpoint)) { client.setEndpoint(endpoint); } return client; }
Example 2
Source File: AWSBinaryStore.java From usergrid with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: FileProcessor.java From AWS-MIMIC-IIItoOMOP with Apache License 2.0 | 5 votes |
public FileProcessor(String table) throws ClassNotFoundException, SQLException { client = new AmazonS3Client(); client.setRegion(Region.getRegion(Regions.US_WEST_2)); connection = new RedshiftConnection().getConnection(); this.table = table; }
Example 4
Source File: S3ClientProvider.java From micro-server with Apache License 2.0 | 5 votes |
@Bean public AmazonS3Client getClient() { AWSCredentials credentials = getAwsCredentials(); AmazonS3Client amazonS3Client = new AmazonS3Client(credentials, getClientConfiguration()); if (s3Configuration.getRegion() != null) { Region region = Region.getRegion(Regions.fromName(s3Configuration.getRegion())); amazonS3Client.setRegion(region); } return amazonS3Client; }
Example 5
Source File: S3Reconciler.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
@Override public void setup(Context.OperatorContext context) { s3client = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey)); if (region != null) { s3client.setRegion(Region.getRegion(Regions.fromName(region))); } filePath = context.getValue(DAG.APPLICATION_PATH); try { fs = FileSystem.newInstance(new Path(filePath).toUri(), new Configuration()); } catch (IOException e) { logger.error("Unable to create FileSystem: {}", e.getMessage()); } super.setup(context); }
Example 6
Source File: S3FeaturesDemoTest.java From Scribengin with GNU Affero General Public License v3.0 | 5 votes |
public void init() throws Exception { /* * Create your credentials file at ~/.aws/credentials * (C:\Users\USER_NAME\.aws\credentials for Windows users) and save the * following lines after replacing the underlined values with your own. * * [default] * aws_access_key_id=YOUR_ACCESS_KEY_ID * aws_secret_access_key=YOUR_SECRET_ACCESS_KEY */ s3Client = new AmazonS3Client(); Region region = Region.getRegion(Regions.US_WEST_2); //Region region = Region.getRegion(Regions.SA_EAST_1); s3Client.setRegion(region); }
Example 7
Source File: AwsClientFactory.java From soundwave with Apache License 2.0 | 4 votes |
public static AmazonS3Client createS3Client(Region region) { Preconditions.checkNotNull(region); AmazonS3Client s3Client = new AmazonS3Client(getCredentialProvider()); s3Client.setRegion(region); return s3Client; }
Example 8
Source File: S3Client.java From Scribengin with GNU Affero General Public License v3.0 | 4 votes |
@PostConstruct public void onInit() { s3Client = new AmazonS3Client(); s3Client.setRegion(region); }