List of usage examples for com.amazonaws.services.s3.model CannedAccessControlList BucketOwnerRead
CannedAccessControlList BucketOwnerRead
To view the source code for com.amazonaws.services.s3.model CannedAccessControlList BucketOwnerRead.
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;/*from w w w. ja v a 2 s . 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 w w w .j a va2 s . co 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; }