List of usage examples for com.amazonaws.services.s3 AmazonS3Client AmazonS3Client
@SdkInternalApi AmazonS3Client(AmazonS3ClientParams s3ClientParams)
From source file:org.boriken.s3fileuploader.S3SampleRefactored.java
License:Open Source License
public static void main(String[] args) throws IOException { /*/* ww w .j av a2 s . com*/ * Important: Be sure to fill in your AWS access credentials in the * AwsCredentials.properties file before you try to run this * sample. * http://aws.amazon.com/security-credentials */ AmazonS3 s3 = new AmazonS3Client(new PropertiesCredentials( S3SampleRefactored.class.getResourceAsStream("../conf/AwsCredentials.properties"))); // String bucketName = "chamakits-my-first-s3-bucket-" + UUID.randomUUID(); String bucketName = "chamakits-HelloS3"; String key = "somekey"; System.out.println("==========================================="); System.out.println("Getting Started with Amazon S3"); System.out.println("===========================================\n"); try { // createBucket(s3,bucketName); // listBuckets(s3); // createFile(s3,bucketName,key); // downloadFile(s3,bucketName,key); // listFiles(s3, bucketName,""); // deleteFile(s3, bucketName, key); // deleteBucket(s3, bucketName); listFiles(s3, bucketName, ""); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means your request made it " + "to Amazon S3, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with S3, " + "such as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }
From source file:org.broadleafcommerce.vendor.amazon.s3.S3FileServiceProvider.java
License:Apache License
protected AmazonS3Client getAmazonS3Client(S3Configuration s3config) { AmazonS3Client client = configClientMap.get(s3config); if (client == null) { client = new AmazonS3Client(getAWSCredentials(s3config)); client.setRegion(s3config.getDefaultBucketRegion()); if (s3config.getEndpointURI() != null) { client.setEndpoint(s3config.getEndpointURI()); }//from w ww. j a v a 2 s . com configClientMap.put(s3config, client); } return client; }
From source file:org.caboclo.clients.AmazonClient.java
License:Open Source License
private AmazonS3 getS3_() throws AmazonClientException { AmazonS3 s3_;/*from w w w . ja va 2s . co m*/ S3ClientOptions s3ClientOptions; // AWSCredentials credentials = new BasicAWSCredentials(Constants.EC2_ACCESS_KEY, Constants.EC2_SECRET_KEY); AWSCredentials credentials = new BasicAWSCredentials(getAuthenticationParameter(ACCESS_KEY), getAuthenticationParameter(SECRET_KEY)); s3_ = new AmazonS3Client(credentials); s3ClientOptions = new S3ClientOptions(); //s3_.setEndpoint(Constants.EC2_END_POINT); s3ClientOptions.setPathStyleAccess(true); s3_.setS3ClientOptions(s3ClientOptions); System.out.println(s3_.listBuckets()); return s3_; }
From source file:org.chombo.util.ConfigurationLoader.java
License:Apache License
/** * @param confFilePath/*from w w w . ja v a 2 s.c om*/ * @return * @throws IOException */ private boolean loadConfigS3(String confFilePath) throws IOException { Matcher matcher = s3pattern.matcher(confFilePath); matcher.matches(); String bucket = matcher.group(1); String key = matcher.group(2); AmazonS3 s3 = new AmazonS3Client( new PropertiesCredentials(Utility.class.getResourceAsStream("AwsCredentials.properties"))); S3Object object = s3.getObject(new GetObjectRequest(bucket, key)); InputStream fis = object.getObjectContent(); List<String> lines = getConfigLines(fis); setFilteredConfiguration(lines); return true; }
From source file:org.chombo.util.Utility.java
License:Apache License
private static boolean loadConfigS3(Configuration conf, String confFilePath) throws IOException { Matcher matcher = s3pattern.matcher(confFilePath); matcher.matches();/*from ww w .j ava 2s .c o m*/ String bucket = matcher.group(1); String key = matcher.group(2); AmazonS3 s3 = new AmazonS3Client( new PropertiesCredentials(Utility.class.getResourceAsStream("AwsCredentials.properties"))); S3Object object = s3.getObject(new GetObjectRequest(bucket, key)); InputStream is = object.getObjectContent(); Properties configProps = new Properties(); configProps.load(is); for (Object keyObj : configProps.keySet()) { String keySt = keyObj.toString(); conf.set(keySt, configProps.getProperty(keySt)); } return true; }
From source file:org.clothocad.phagebook.adaptors.S3Adapter.java
public static void initializeUserFolder(Person pers) { String clothoId = pers.getId(); AWSCredentials credentials = new BasicAWSCredentials(S3Credentials.getUsername(), S3Credentials.getPassword()); AmazonS3 s3client = new AmazonS3Client(credentials); System.out.println("Login Complete"); // list buckets for (Bucket bucket : s3client.listBuckets()) { System.out.println(" - " + bucket.getName()); }/*from w ww.ja v a 2 s . com*/ System.out.println("Clotho id " + clothoId); createS3Folder("phagebookaws", clothoId, s3client); //------------TESTING BEFORE INTEGRATED INTO PROFILE------------ /*String fileName = clothoId + "/" + "profilePicture.jpg"; String picturePath = "C:\\Users\\azula\\Pictures\\AllisonDurkan.jpg"; s3client.putObject(new PutObjectRequest("phagebookaws", fileName, new File(picturePath)) .withCannedAcl(CannedAccessControlList.PublicRead));*/ }
From source file:org.clothocad.phagebook.adaptors.S3Adapter.java
public static void uploadProfilePicture(String clothoId, String filePath) { //String clothoId = pers.getId(); AWSCredentials credentials = new BasicAWSCredentials(S3Credentials.getUsername(), S3Credentials.getPassword()); System.out.println("Login Complete"); AmazonS3 s3client = new AmazonS3Client(credentials); String fileName = clothoId + "/" + "profilePicture.jpg"; s3client.putObject(new PutObjectRequest("phagebookaws", fileName, new File(filePath)) .withCannedAcl(CannedAccessControlList.PublicRead)); }
From source file:org.clothocad.phagebook.adaptors.S3Adapter.java
public static void uploadProfilePicture(String clothoId, File file) { AWSCredentials credentials = new BasicAWSCredentials(S3Credentials.getUsername(), S3Credentials.getPassword()); System.out.println("Login Complete"); AmazonS3 s3client = new AmazonS3Client(credentials); String fileName = clothoId + "/" + "profilePicture.jpg"; s3client.putObject(new PutObjectRequest("phagebookaws", fileName, file) .withCannedAcl(CannedAccessControlList.PublicRead)); }
From source file:org.cloudifysource.esc.driver.provisioning.privateEc2.AmazonS3Uploader.java
License:Open Source License
public AmazonS3Uploader(final String accessKey, final String secretKey, final String locationId) { this.accessKey = accessKey; final AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); this.s3client = new AmazonS3Client(credentials); if (locationId != null) { this.s3client.setRegion(RegionUtils.convertLocationId2Region(locationId)); }// w ww. j av a2 s . co m }
From source file:org.cloudifysource.s3client.S3AWSAPIDeployMojo.java
License:Open Source License
public void execute() throws MojoExecutionException, MojoFailureException { BlobStoreContext context = null;/*from ww w . j a v a 2s . co m*/ try { getLog().info("Using aws-sdk-java"); AWSCredentials awsCredentials = new BasicAWSCredentials(user, key); AmazonS3 s3 = new AmazonS3Client(awsCredentials); uploadFile(s3, container, target, source); } catch (Exception e) { throw new MojoFailureException("Failed put operation", e); } finally { if (context != null) { context.close(); } } }