software.amazon.awssdk.services.s3.model.ObjectCannedACL Java Examples
The following examples show how to use
software.amazon.awssdk.services.s3.model.ObjectCannedACL.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AmazonMachineLearningIntegrationTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
private static void setUpS3() { s3 = S3Client.builder() .credentialsProvider(CREDENTIALS_PROVIDER_CHAIN) .region(Region.US_EAST_1) .build(); s3.createBucket(CreateBucketRequest.builder().bucket(BUCKET_NAME).build()); Waiter.run(() -> s3.putObject(PutObjectRequest.builder() .bucket(BUCKET_NAME) .key(KEY) .acl(ObjectCannedACL.PUBLIC_READ) .build(), RequestBody.fromBytes(DATA.getBytes()))) .ignoringException(NoSuchBucketException.class) .orFail(); }
Example #2
Source File: S3PutObject.java From piper with Apache License 2.0 | 6 votes |
@Override public Object handle (TaskExecution aTask) throws Exception { AmazonS3URI s3Uri = new AmazonS3URI(aTask.getRequiredString("uri")); String bucketName = s3Uri.getBucket(); String key = s3Uri.getKey(); S3Client s3 = S3Client.builder().build(); s3.putObject(PutObjectRequest.builder() .bucket(bucketName) .key(key) .acl(aTask.getString("acl")!=null?ObjectCannedACL.fromValue(aTask.getString("acl")):null) .build(), Paths.get(aTask.getRequiredString("filepath"))); return null; }
Example #3
Source File: AWSFileStore.java From para with Apache License 2.0 | 5 votes |
@Override public String store(String path, InputStream data) { if (StringUtils.startsWith(path, "/")) { path = path.substring(1); } if (StringUtils.isBlank(path) || data == null) { return null; } int maxFileSizeMBytes = Config.getConfigInt("para.s3.max_filesize_mb", 10); try { if (data.available() > 0 && data.available() <= (maxFileSizeMBytes * 1024 * 1024)) { Map<String, String> om = new HashMap<String, String>(3); om.put(HttpHeaders.CACHE_CONTROL, "max-age=15552000, must-revalidate"); // 180 days if (path.endsWith(".gz")) { om.put(HttpHeaders.CONTENT_ENCODING, "gzip"); path = path.substring(0, path.length() - 3); } PutObjectRequest por = PutObjectRequest.builder(). bucket(bucket).key(path). metadata(om). acl(ObjectCannedACL.PUBLIC_READ). storageClass(StorageClass.REDUCED_REDUNDANCY).build(); s3.putObject(por, RequestBody.fromInputStream(data, data.available())); //.bucket, path, data, om return Utils.formatMessage(S3_URL, new DefaultAwsRegionProviderChain().getRegion().id(), bucket, path); } } catch (IOException e) { logger.error(null, e); } finally { try { data.close(); } catch (IOException ex) { logger.error(null, ex); } } return null; }