Java Code Examples for com.amazonaws.services.s3.model.PutObjectRequest#withCannedAcl()
The following examples show how to use
com.amazonaws.services.s3.model.PutObjectRequest#withCannedAcl() .
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: OldS3NotebookRepo.java From zeppelin with Apache License 2.0 | 5 votes |
@Override public void save(Note note, AuthenticationInfo subject) throws IOException { String json = note.toJson(); String key = user + "/" + "notebook" + "/" + note.getId() + "/" + "note.json"; File file = File.createTempFile("note", "json"); try { Writer writer = new OutputStreamWriter(new FileOutputStream(file)); writer.write(json); writer.close(); PutObjectRequest putRequest = new PutObjectRequest(bucketName, key, file); if (useServerSideEncryption) { // Request server-side encryption. ObjectMetadata objectMetadata = new ObjectMetadata(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); putRequest.setMetadata(objectMetadata); } if (objectCannedAcl != null) { putRequest.withCannedAcl(objectCannedAcl); } s3client.putObject(putRequest); } catch (AmazonClientException ace) { throw new IOException("Unable to store note in S3: " + ace, ace); } finally { FileUtils.deleteQuietly(file); } }
Example 2
Source File: S3NotebookRepo.java From zeppelin with Apache License 2.0 | 5 votes |
@Override public void save(Note note, AuthenticationInfo subject) throws IOException { String json = note.toJson(); String key = rootFolder + "/" + buildNoteFileName(note); File file = File.createTempFile("note", "zpln"); try { Writer writer = new OutputStreamWriter(new FileOutputStream(file)); writer.write(json); writer.close(); PutObjectRequest putRequest = new PutObjectRequest(bucketName, key, file); if (useServerSideEncryption) { // Request server-side encryption. ObjectMetadata objectMetadata = new ObjectMetadata(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); putRequest.setMetadata(objectMetadata); } if (objectCannedAcl != null) { putRequest.withCannedAcl(objectCannedAcl); } s3client.putObject(putRequest); } catch (AmazonClientException ace) { throw new IOException("Fail to store note: " + note.getPath() + " in S3", ace); } finally { FileUtils.deleteQuietly(file); } }
Example 3
Source File: S3FileOutputPlugin.java From embulk-output-s3 with MIT License | 5 votes |
private void putFile(Path from, String key) { PutObjectRequest request = new PutObjectRequest(bucket, key, from.toFile()); if (cannedAccessControlListOptional.isPresent()) { request.withCannedAcl(cannedAccessControlListOptional.get()); } client.putObject(request); }