List of usage examples for com.amazonaws.services.s3.model CannedAccessControlList AuthenticatedRead
CannedAccessControlList AuthenticatedRead
To view the source code for com.amazonaws.services.s3.model CannedAccessControlList AuthenticatedRead.
Click Source Link
From source file:com.mindtree.maven.S3Mojo.java
License:Apache License
private void createBucketAndUploadFiles() throws MojoExecutionException { for (int i = 0; i < bucketNames.length; i++) { String path = bucketNames[i]; int index = path.indexOf("/"); logger.debug("Got index of / : " + index); logger.debug("Trying upload for files with path : " + path); // The path to upload can have subdirectories hence only the first // directory (root) is required String rootBucket = path; if (index == 0) { logger.debug("Unique name bucket creation is required"); rootBucket = UNIQUE;//www . j a v a 2s.c o m } else if (index != -1) { logger.debug("Given name bucket creation is required"); rootBucket = rootBucket.substring(0, index); } Bucket bucket = createS3Bucket(rootBucket); if (bucket != null) { List<File> fileList = mapFiles.get(path); logger.debug("Got fileList as null :: " + (fileList == null)); if (fileList != null) { logger.debug("Size of fileList :" + fileList.size()); } CannedAccessControlList cacl = CannedAccessControlList.Private; if (accessControls[i].equalsIgnoreCase(CannedAccessControlList.AuthenticatedRead.toString())) { cacl = CannedAccessControlList.AuthenticatedRead; } else if (accessControls[i] .equalsIgnoreCase(CannedAccessControlList.BucketOwnerFullControl.toString())) { cacl = CannedAccessControlList.BucketOwnerFullControl; } else if (accessControls[i].equalsIgnoreCase(CannedAccessControlList.BucketOwnerRead.toString())) { cacl = CannedAccessControlList.BucketOwnerRead; } else if (accessControls[i] .equalsIgnoreCase(CannedAccessControlList.LogDeliveryWrite.toString())) { cacl = CannedAccessControlList.LogDeliveryWrite; } else if (accessControls[i].equalsIgnoreCase(CannedAccessControlList.Private.toString())) { cacl = CannedAccessControlList.Private; } else if (accessControls[i].equalsIgnoreCase(CannedAccessControlList.PublicRead.toString())) { cacl = CannedAccessControlList.PublicRead; } else if (accessControls[i].equalsIgnoreCase(CannedAccessControlList.PublicReadWrite.toString())) { cacl = CannedAccessControlList.PublicReadWrite; } String bucketName = bucket.getName() + bucketNames[i].substring(bucketNames[i].indexOf("/")); logger.debug("File to upload to :" + bucketName); if (fileList != null && fileList.size() > 0) { if (!retainFolderStructure) { logger.debug("Not retaining folder structure and uploadinf files"); System.out.println(cacl.toString()); List<PutObjectResult> fileUploadResults = S3Helper.uploadFiles(fileList, bucketName, s3, cacl); } else { logger.debug("Uploading with retained dir structure"); List<PutObjectResult> fileUploadResults = S3Helper.uploadFiles(fileList, bucketName, s3, cacl, root); } } } } }
From source file:org.alanwilliamson.amazon.AmazonKey.java
License:Open Source License
/** * private | public-read | public-read-write | authenticated-read | bucket-owner-read | bucket-owner-full-control | log-delivery-write * * @param acl//from ww w .j a v a 2 s .c o m * @return */ public CannedAccessControlList getAmazonCannedAcl(String acl) { if (acl.equalsIgnoreCase("private")) return CannedAccessControlList.Private; else if (acl.equalsIgnoreCase("public-read") || acl.equalsIgnoreCase("publicread")) return CannedAccessControlList.PublicRead; else if (acl.equalsIgnoreCase("public-read-write") || acl.equalsIgnoreCase("publicreadwrite")) return CannedAccessControlList.PublicReadWrite; else if (acl.equalsIgnoreCase("authenticated-read") || acl.equalsIgnoreCase("authenticatedread")) return CannedAccessControlList.AuthenticatedRead; else if (acl.equalsIgnoreCase("bucket-owner-read") || acl.equalsIgnoreCase("bucketownerread")) return CannedAccessControlList.BucketOwnerRead; else if (acl.equalsIgnoreCase("bucket-owner-full-control") || acl.equalsIgnoreCase("bucketownerfullcontrol")) return CannedAccessControlList.BucketOwnerFullControl; else if (acl.equalsIgnoreCase("log-delivery-write") || acl.equalsIgnoreCase("logdeliverywrite")) return CannedAccessControlList.LogDeliveryWrite; else return CannedAccessControlList.Private; }
From source file:org.apache.usergrid.apm.util.CrashLogUploadToS3Simulator.java
License:Apache License
public static boolean uploadSimulatedCrashLogsToS3(String appId, String fileName) { DeploymentConfig config = DeploymentConfig.geDeploymentConfig(); AWSCredentials credentials = new BasicAWSCredentials(config.getAccessKey(), config.getSecretKey()); AmazonS3Client s3Client = new AmazonS3Client(credentials); PutObjectRequest putObjectRequest;// w w w . j a va2 s. c om String s3FullFileName = config.getEnvironment() + "/crashlog/" + appId + "/" + fileName; try { ObjectMetadata metaData = new ObjectMetadata(); metaData.setHeader(Headers.S3_CANNED_ACL, CannedAccessControlList.AuthenticatedRead); putObjectRequest = new PutObjectRequest(config.getS3LogBucket(), s3FullFileName, new ByteArrayInputStream(fileName.getBytes("UTF-8")), null); PutObjectResult result = s3Client.putObject(putObjectRequest); return true; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return false; }
From source file:org.apache.usergrid.apm.util.GenerateSimulatedMobileData.java
License:Apache License
public static boolean uploadSimulatedCrashLogsToS3(App app, String fileName) { DeploymentConfig config = DeploymentConfig.geDeploymentConfig(); AWSCredentials credentials = new BasicAWSCredentials(config.getAccessKey(), config.getSecretKey()); AmazonS3Client s3Client = new AmazonS3Client(credentials); PutObjectRequest putObjectRequest;//from www .ja va 2 s . c o m String s3FullFileName = config.getEnvironment() + "/" + config.getS3CrashLogFolder() + "/" + app.getFullAppName() + "/" + fileName; String sampleCrashFileName = null; if (fileName.endsWith(".crash")) //it's an iOS crash file sampleCrashFileName = "ios-crash-log-example.txt"; else if (fileName.endsWith(".stacktrace")) sampleCrashFileName = "android-crash-log-example.txt"; try { ObjectMetadata metaData = new ObjectMetadata(); metaData.setHeader(Headers.S3_CANNED_ACL, CannedAccessControlList.AuthenticatedRead); InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(sampleCrashFileName); putObjectRequest = new PutObjectRequest(config.getS3LogBucket(), s3FullFileName, is, null); //new ByteArrayInputStream( //fileName.getBytes("UTF-8")),null); PutObjectResult result = s3Client.putObject(putObjectRequest); return true; } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:org.springframework.aws.ivy.S3Repository.java
License:Apache License
public void setAcl(String acl) { if ("PRIVATE".equals(acl)) { this.acl = CannedAccessControlList.Private; } else if ("PUBLIC_READ".equals(acl)) { this.acl = CannedAccessControlList.PublicRead; } else if ("PUBLIC_READ_WRITE".equals(acl)) { this.acl = CannedAccessControlList.PublicReadWrite; } else if ("AUTHENTICATED_READ".equals(acl)) { this.acl = CannedAccessControlList.AuthenticatedRead; } else {/* w ww. j a v a2 s . c o m*/ throw new IllegalArgumentException("Unknown acl " + acl); } }