List of usage examples for com.amazonaws.services.s3 AmazonS3Client AmazonS3Client
@SdkInternalApi AmazonS3Client(AmazonS3ClientParams s3ClientParams)
From source file:internal.diff.aws.configuration.AmazonS3ClientConfiguration.java
License:Apache License
@Bean public AmazonS3Client amazonS3Client() { BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey); return new AmazonS3Client(awsCredentials); }
From source file:io.andromeda.logcollector.S3FileReader.java
License:Apache License
public S3FileReader(String profile, String region) { this.s3 = new AmazonS3Client(new ProfileCredentialsProvider(profile)); s3.setRegion(com.amazonaws.regions.Region.getRegion(Regions.fromName(region))); }
From source file:io.dockstore.common.FileProvisioning.java
License:Apache License
private static AmazonS3 getAmazonS3Client(HierarchicalINIConfiguration config) { AmazonS3 s3Client = new AmazonS3Client(new ClientConfiguration().withSignerOverride("S3Signer")); if (config.containsKey(S3_ENDPOINT)) { final String endpoint = config.getString(S3_ENDPOINT); LOG.info("found custom S3 endpoint, setting to {}", endpoint); s3Client.setEndpoint(endpoint);/* w ww. j ava 2 s .co m*/ s3Client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true)); } return s3Client; }
From source file:io.jeffrey.web.Wake.java
public static void main(String[] args) throws Exception { String configFilename = ".wake"; for (int k = 0; k < args.length - 1; k++) { if ("--config".equals(args[k]) || "-c".equals(args[k])) { configFilename = args[k + 1]; }/* w w w . j a v a 2 s . c o m*/ } File configFile = new File(configFilename); Config config; if (configFile.exists()) { FileReader reader = new FileReader(configFile); try { config = new Config(reader); } finally { reader.close(); ; } } else { // roll with the defaults (thus, no deployment config = new Config(); } ArrayList<String> errors = new ArrayList<>(); File input = config.getFile(Config.ConfigFile.Input, errors); File merge = config.getFile(Config.ConfigFile.Merge, errors); File output = null; String bucket = config.get(Config.ConfigKey.Bucket, false, errors); String redirectBucket = config.get(Config.ConfigKey.RedirectBucket, false, errors); AmazonS3 s3 = null; if (bucket != null) { String accessKey = config.get(Config.ConfigKey.AccessKey, true, errors); String secret = config.get(Config.ConfigKey.SecretKey, true, errors); AWSCredentials credentials = new BasicAWSCredentials(accessKey, secret); s3 = new AmazonS3Client(credentials); } else { output = config.getFile(Config.ConfigFile.Output, errors); } if (errors.size() > 0) { System.err.println("There were too many errors:"); errors.forEach((error) -> System.err.println(error)); return; } // load them from disk DiskLoaderStage raw = new DiskLoaderStage(input); // sort them for giggles SortByOrderStage sorted = new SortByOrderStage(raw); // inject the topology (connect the pages together according to the one true tree) InjectTopologyStage withTopology = new InjectTopologyStage(sorted); // inject snippets SnippetInjectorStage withSnippets = new SnippetInjectorStage(withTopology); // put templates into place TemplateCrossStage withTemplates = new TemplateCrossStage(withSnippets); // assemble the manifest InMemoryAssembler assembly = new InMemoryAssembler(merge, withTemplates); // build the spelling page // TODO: clean this up final StringBuilder spelling = new StringBuilder(); spelling.append("<pre>"); assembly.validate((url, html) -> { try { spelling.append("<h1>" + url + "</h1>\n"); JLanguageTool langTool = new JLanguageTool(new AmericanEnglish()); langTool.activateDefaultPatternRules(); Document doc = Jsoup.parse(html); Elements elements = doc.select("p"); elements.forEach((element) -> { String plain = new HtmlToPlainText().getPlainText(element); plain = plain.replaceAll(" \\s*", " "); plain = plain.replaceAll("\\s* ", " "); try { List<RuleMatch> matches = langTool.check(plain); if (matches.size() > 0) { spelling.append(plain); spelling.append("\n"); for (RuleMatch match : matches) { spelling.append("Potential error at line " + match.getLine() + ", column " + match.getColumn() + ": " + match.getMessage()); spelling.append("\n"); spelling.append("Suggested correction: " + match.getSuggestedReplacements()); spelling.append("\n"); } } } catch (IOException ioe) { throw new RuntimeException(ioe); } }); } catch (Exception err) { System.err.println("Exception checking:" + url); err.printStackTrace(); } }); spelling.append("</pre>"); // let's simply write it to disk PutTarget target; if (s3 == null) { System.out.println("writing to disk"); target = new DiskPutTarget(output); } else { System.out.println("writing to s3"); target = new S3PutObjectTarget(bucket, s3); } assembly.put("__spelling.html", spelling.toString()); // engage! assembly.assemble(target); }
From source file:io.konig.etl.aws.CamelEtlRouteController.java
License:Apache License
@Bean AmazonS3Client s3Client() { AWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY); return new AmazonS3Client(credentials); }
From source file:io.milton.s3.AmazonS3ManagerImpl.java
License:Open Source License
/** * You can choose the geographical region where Amazon S3 will store the * buckets you create. You might choose a region to optimize latency, * minimize costs, or address regulator requirements. * //from w w w. ja v a 2 s.c om * @param region */ public AmazonS3ManagerImpl(Region region) { LOG.info("Create an instance of the AmazonS3Client class by providing your " + "AWS Account or IAM user credentials (Access Key ID, Secret Access Key)"); // Create an instance of the AmazonS3Client class by providing your AWS // Account or IAM user credentials (Access Key ID, Secret Access Key) amazonS3Client = new AmazonS3Client(new ClasspathPropertiesFileCredentialsProvider()); amazonS3Client.setRegion(region); }
From source file:io.seldon.resources.external.S3FileStreamer.java
License:Apache License
public InputStream getResourceStream(String reference) throws IOException { logger.info("Reading file from s3://" + reference); AmazonS3Client client;/*from w w w.ja va 2 s . c om*/ if (creds != null) { client = new AmazonS3Client(creds); } else { client = new AmazonS3Client(); } String[] bucketAndFile = reference.split("/", 2); if (bucketAndFile.length != 2) { return null; } S3Object object = client.getObject(new GetObjectRequest(bucketAndFile[0], bucketAndFile[1])); if (reference.endsWith(".gz")) { return new S3ObjectInputStreamWrapper(new GZIPInputStream(object.getObjectContent()), client); } else { return new S3ObjectInputStreamWrapper(object.getObjectContent(), client); } }
From source file:io.stallion.services.S3StorageService.java
License:Open Source License
public S3StorageService() { CloudStorageSettings settings = Settings.instance().getCloudStorage(); if (settings == null) { throw new ConfigException( "You are missing the section [cloudStorage]\naccessToken=...\nsecret=... in your stallion.toml"); }/*from w w w. j ava 2s .com*/ if (empty(settings.getAccessToken())) { throw new ConfigException( "You are missing the setting accessKey in the stallion.toml section [cloudStorage]"); } if (empty(settings.getSecret())) { throw new ConfigException( "You are missing the setting secret in the stallion.toml section [cloudStorage]"); } accessToken = settings.getAccessToken(); secret = settings.getSecret(); AWSCredentials credentials = new BasicAWSCredentials(accessToken, secret); client = new AmazonS3Client(credentials); }
From source file:it.openutils.mgnlaws.magnolia.datastore.S3DataStore.java
License:Open Source License
/** * {@inheritDoc}//from w ww.j av a 2 s .c om */ public void init(String homeDir) throws RepositoryException { // init S3 client amazonS3 = new AmazonS3Client(new BasicAWSCredentials(awsAccessKey, awsSecretKey)); // set endpoint if (StringUtils.isNotBlank(endpoint)) { amazonS3.setEndpoint(endpoint); } // init transfer manager transferManager = new TransferManager(amazonS3); // initialize tmp directory if (StringUtils.isNotBlank(tmpPath)) { tmpDirectory = new File(tmpPath); if (!tmpDirectory.exists()) { tmpDirectory.mkdirs(); } } if (tmpDirectory == null || !tmpDirectory.isDirectory()) { tmpDirectory = new File(System.getProperty("java.io.tmpdir")); } if (useCache) { // initialize cache directory if (StringUtils.isNotBlank(cacheDirectoryPath)) { cacheDirectory = new File(cacheDirectoryPath); if (!cacheDirectory.exists()) { cacheDirectory.mkdirs(); } } if (cacheDirectory == null || !cacheDirectory.isDirectory()) { cacheDirectory = new File(System.getProperty("java.io.tmpdir"), cacheName); if (!cacheDirectory.exists()) { cacheDirectory.mkdirs(); } } // create cache manager CacheManager cacheManager; if (StringUtils.startsWith(cacheConfigFile, "classpath:")) { URL configurationFileURL = getClass() .getResource(StringUtils.substringAfter(cacheConfigFile, "classpath:")); cacheManager = CacheManager.newInstance(configurationFileURL); } else { cacheManager = CacheManager.newInstance(cacheConfigFile); } // get cache cache = cacheManager.getCache(cacheName); // register cache listener cache.getCacheEventNotificationService().registerListener(new S3CacheListener(cacheDirectory)); } }
From source file:it.polimi.modaclouds.cpimlibrary.blobmng.AmazonBlobManagerFactory.java
License:Apache License
@Override public CloudBlobManager createCloudBlobManager() { AWSCredentials credentials = null;//w w w .j a v a 2s. c o m try { credentials = new PropertiesCredentials( getClass().getClassLoader().getResourceAsStream("AwsCredentials.properties")); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return new AmazonBlobManager(new AmazonS3Client(credentials)); }