List of usage examples for com.amazonaws.services.s3 AmazonS3Client AmazonS3Client
@SdkInternalApi AmazonS3Client(AmazonS3ClientParams s3ClientParams)
From source file:com.github.rholder.esthree.Main.java
License:Apache License
public void parseGlobalCli(String... args) { command = createCli().parse(args);//from w ww .j av a2 s.c o m command.commandMetadata = MetadataLoader.loadCommand(command.getClass()); command.output = new PrintStream(new BufferedOutputStream(System.out)); // override if keys are specified if (command.accessKey != null || command.secretKey != null) { command.amazonS3Client = new AmazonS3Client( new BasicAWSCredentials(command.accessKey, command.secretKey)); } else { command.amazonS3Client = new AmazonS3Client(); } // override S3 endpoint if specified if (command.endpoint != null) { command.amazonS3Client.setEndpoint(command.endpoint); } }
From source file:com.github.wuic.nut.s3.S3NutDao.java
License:Open Source License
/** * <p>//from w w w. ja va 2 s . com * Initializes a new client based on the instance's credentials. * </p> * * @return the client */ public AmazonS3Client initClient() { return new AmazonS3Client(new BasicAWSCredentials(login, password)); }
From source file:com.grallandco.demos.DBWrite.java
License:Apache License
public static void main(String[] args) throws Exception { AmazonS3 s3;/* w ww . ja va2s. c om*/ if (args.length == 2) { String accessKey = args[0]; String secretKey = args[1]; s3 = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey)); } StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); Properties props = new Properties(); //Properties outProps = new Properties(); // setProperties(); props.setProperty("bootstrap.servers", "localhost:9092"); props.setProperty("group.id", "zookeeper"); props.setProperty("auto.offset.reset", "latest"); //outProps.setProperty("bootstrap.servers", "localhost:9092"); String topic = "poe3"; //final Connection conn = r.connection().hostname("35.166.62.31").port(28015).connect(); //conn.use("poeapi"); //DataStream<String> stream = env.addSource(new FlinkKafkaConsumer09<String>(topic, new SimpleStringSchema(), props)); env.execute(); }
From source file:com.gst.infrastructure.documentmanagement.contentrepository.S3ContentRepository.java
License:Apache License
public S3ContentRepository(final String bucketName, final String secretKey, final String accessKey) { this.s3BucketName = bucketName; this.s3Client = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey)); }
From source file:com.haskins.cloudtrailviewer.core.EventLoader.java
License:Open Source License
/** * Loads events from S3/*w ww .j ava2s .c o m*/ * @param request Object containing request information */ public void loadEventsFromS3(final LoadFileRequest request) { SwingWorker worker = new SwingWorker<Void, Void>() { @Override public Void doInBackground() { int count = 0; List<AwsAccount> accounts = AccountDao.getAllAccounts(true); if (accounts.isEmpty()) { return null; } AwsAccount account = accounts.get(0); String key = account.getKey(); String secret = account.getSecret(); AWSCredentials credentials = new BasicAWSCredentials(key, secret); AmazonS3 s3Client = new AmazonS3Client(credentials); String bucketName = account.getBucket(); if (request.getFilter() == null) { CompositeFilter filters = new CompositeFilter(); filters.addFilter(new AllFilter()); request.setFilter(filters); } List<String> filenames = request.getFilenames(); int total = filenames.size(); for (String filename : filenames) { count++; for (EventLoaderListener l : listeners) { l.processingFile(count, total); } try (InputStream stream = loadEventFromS3(s3Client, bucketName, filename)) { processStream(stream, request.getFilter()); } catch (IOException ioe) { LOGGER.log(Level.WARNING, "Failed to load file : " + filename, ioe); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to load file : " + filename, e); } } for (EventLoaderListener l : listeners) { l.finishedLoading(); } return null; } }; worker.execute(); }
From source file:com.haskins.cloudtrailviewer.dialog.s3filechooser.S3FileList.java
License:Open Source License
private AmazonS3 getS3Client() { AWSCredentials credentials = new BasicAWSCredentials(currentAccount.getKey(), currentAccount.getSecret()); return new AmazonS3Client(credentials); }
From source file:com.haskins.cloudtrailviewer.dialog.S3FileChooser.java
License:Open Source License
private void reloadContents() { loadingLabel.setVisible(true);// w ww .ja v a 2 s.co m this.s3ListModel.clear(); String bucketName = currentAccount.getBucket(); ListObjectsRequest listObjectsRequest = new ListObjectsRequest(); listObjectsRequest.setBucketName(bucketName); listObjectsRequest.setPrefix(prefix); listObjectsRequest.setDelimiter("/"); AWSCredentials credentials = new BasicAWSCredentials(currentAccount.getKey(), currentAccount.getSecret()); AmazonS3 s3Client = new AmazonS3Client(credentials); try { ObjectListing objectListing = s3Client.listObjects(listObjectsRequest); // Add .. if not at root if (prefix.trim().length() != 0) { S3ListModel model = new S3ListModel(MOVE_BACK, MOVE_BACK, S3ListModel.FILE_BACK); this.s3ListModel.addElement(model); } // these are directories List<String> directories = objectListing.getCommonPrefixes(); for (String directory : directories) { String dir = stripPrefix(directory); int lastSlash = dir.lastIndexOf("/"); String strippeDir = dir.substring(0, lastSlash); String alias = dir; if (isAccountNumber(strippeDir)) { if (aliasMap.containsKey(strippeDir)) { alias = aliasMap.get(strippeDir); } } S3ListModel model = new S3ListModel(dir, alias, S3ListModel.FILE_DIR); this.s3ListModel.addElement(model); } // these are files List<S3ObjectSummary> objectSummaries = objectListing.getObjectSummaries(); for (final S3ObjectSummary objectSummary : objectSummaries) { String file = stripPrefix(objectSummary.getKey()); S3ListModel model = new S3ListModel(file, file, S3ListModel.FILE_DOC); this.s3ListModel.addElement(model); } loadingLabel.setVisible(false); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.igeekinc.indelible.indeliblefs.uniblock.casstore.s3.S3CASStore.java
License:Open Source License
protected void initInternal() { credentials = new BasicAWSCredentials(accessKey, secretKey); s3Client = new AmazonS3Client(credentials); List<Bucket> bucketList = s3Client.listBuckets(); for (Bucket checkBucket : bucketList) { if (checkBucket.getName().equals(storeID.toString())) { return; // It already exists }//from w w w . j a va 2 s .c om } if (region != null) s3Client.createBucket(storeID.toString(), region); // storeID's should be globally unique so we don't worry about bucket name collisions else s3Client.createBucket(storeID.toString()); }
From source file:com.ikanow.infinit.e.harvest.extraction.document.file.AwsInfiniteFile.java
License:Open Source License
public AwsInfiniteFile(String url, NtlmPasswordAuthentication auth) throws IOException { BasicAWSCredentials awsAuth = new BasicAWSCredentials(auth.getUsername(), auth.getPassword()); AmazonS3Client client = new AmazonS3Client(awsAuth); _awsClient = (Object) client; getBucketAndObjectName(url, false);/*from ww w. j av a 2s. com*/ }
From source file:com.images3.data.impl.AmazonS3ClientPool.java
License:Apache License
private AmazonS3 createAmazonS3Client(String accessKey, String secretKey) { return new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey)); }