List of usage examples for com.amazonaws.services.s3 Headers SERVER_SIDE_ENCRYPTION
String SERVER_SIDE_ENCRYPTION
To view the source code for com.amazonaws.services.s3 Headers SERVER_SIDE_ENCRYPTION.
Click Source Link
From source file:org.eclipse.hawkbit.artifact.repository.S3Repository.java
License:Open Source License
private ObjectMetadata createObjectMetadata(final String mdMD5Hash16, final String contentType, final File file) { final ObjectMetadata objectMetadata = new ObjectMetadata(); final String mdMD5Hash64 = BaseEncoding.base64() .encode(BaseEncoding.base16().lowerCase().decode(mdMD5Hash16)); objectMetadata.setContentMD5(mdMD5Hash64); objectMetadata.setContentType(contentType); objectMetadata.setContentLength(file.length()); objectMetadata.setHeader("x-amz-meta-md5chksum", mdMD5Hash64); if (s3Properties.isServerSideEncryption()) { objectMetadata.setHeader(Headers.SERVER_SIDE_ENCRYPTION, s3Properties.getServerSideEncryptionAlgorithm()); }/*w ww . j a v a 2 s. c om*/ return objectMetadata; }
From source file:org.icgc.dcc.storage.client.transport.StorageService.java
License:Open Source License
public void uploadPart(DataChannel channel, Part part, String objectId, String uploadId) throws IOException { retry.execute(new RetryCallback<Void, IOException>() { @Override/*from w w w. j a v a 2 s .c om*/ public Void doWithRetry(RetryContext ctx) throws IOException { log.debug("Upload Part URL: {}", part.getUrl()); final RequestCallback callback = request -> { HttpHeaders requestHeader = request.getHeaders(); requestHeader.setContentLength(channel.getLength()); try (OutputStream os = request.getBody()) { channel.writeTo(os); } }; final ResponseExtractor<HttpHeaders> headersExtractor = response -> response.getHeaders(); try { HttpHeaders headers = dataTemplate.execute(new URI(part.getUrl()), HttpMethod.PUT, callback, headersExtractor); try { finalizeUploadPart(objectId, uploadId, part.getPartNumber(), channel.getMd5(), cleanUpETag(headers.getETag()), disableChecksum(headers)); } catch (NotRetryableException e) { log.warn("Checksum failed for part #{}, MD5={}, ETAG={} : {}", part, channel.getMd5(), headers.getETag(), e); throw new RetryableException(e); } } catch (NotResumableException | NotRetryableException e) { log.error("Could not proceed. Failed to send part for part number: {}", part.getPartNumber(), e); throw e; } catch (Throwable e) { log.warn("Failed to send part for part #{} : {}", part.getPartNumber(), e); channel.reset(); throw new RetryableException(e); } return null; } private boolean disableChecksum(HttpHeaders headers) { List<String> encryption = headers.get(Headers.SERVER_SIDE_ENCRYPTION); if (encryption != null && !encryption.isEmpty()) { return encryption.contains(SSEAlgorithm.KMS.getAlgorithm()); } return false; } }); }