Java Code Examples for org.jets3t.service.model.S3Object#setServerSideEncryptionAlgorithm()
The following examples show how to use
org.jets3t.service.model.S3Object#setServerSideEncryptionAlgorithm() .
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: Jets3tNativeFileSystemStore.java From hadoop with Apache License 2.0 | 6 votes |
public void storeLargeFile(String key, File file, byte[] md5Hash) throws IOException { S3Object object = new S3Object(key); object.setDataInputFile(file); object.setContentType("binary/octet-stream"); object.setContentLength(file.length()); object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm); if (md5Hash != null) { object.setMd5Hash(md5Hash); } List<StorageObject> objectsToUploadAsMultipart = new ArrayList<StorageObject>(); objectsToUploadAsMultipart.add(object); MultipartUtils mpUtils = new MultipartUtils(multipartBlockSize); try { mpUtils.uploadObjects(bucket.getName(), s3Service, objectsToUploadAsMultipart, null); } catch (Exception e) { handleException(e, key); } }
Example 2
Source File: Jets3tNativeFileSystemStore.java From hadoop with Apache License 2.0 | 6 votes |
@Override public void copy(String srcKey, String dstKey) throws IOException { try { if(LOG.isDebugEnabled()) { LOG.debug("Copying srcKey: " + srcKey + "to dstKey: " + dstKey + "in bucket: " + bucket.getName()); } if (multipartEnabled) { S3Object object = s3Service.getObjectDetails(bucket, srcKey, null, null, null, null); if (multipartCopyBlockSize > 0 && object.getContentLength() > multipartCopyBlockSize) { copyLargeFile(object, dstKey); return; } } S3Object dstObject = new S3Object(dstKey); dstObject.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm); s3Service.copyObject(bucket.getName(), srcKey, bucket.getName(), dstObject, false); } catch (ServiceException e) { handleException(e, srcKey); } }
Example 3
Source File: Jets3tNativeFileSystemStore.java From big-c with Apache License 2.0 | 6 votes |
public void storeLargeFile(String key, File file, byte[] md5Hash) throws IOException { S3Object object = new S3Object(key); object.setDataInputFile(file); object.setContentType("binary/octet-stream"); object.setContentLength(file.length()); object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm); if (md5Hash != null) { object.setMd5Hash(md5Hash); } List<StorageObject> objectsToUploadAsMultipart = new ArrayList<StorageObject>(); objectsToUploadAsMultipart.add(object); MultipartUtils mpUtils = new MultipartUtils(multipartBlockSize); try { mpUtils.uploadObjects(bucket.getName(), s3Service, objectsToUploadAsMultipart, null); } catch (Exception e) { handleException(e, key); } }
Example 4
Source File: Jets3tNativeFileSystemStore.java From big-c with Apache License 2.0 | 6 votes |
@Override public void copy(String srcKey, String dstKey) throws IOException { try { if(LOG.isDebugEnabled()) { LOG.debug("Copying srcKey: " + srcKey + "to dstKey: " + dstKey + "in bucket: " + bucket.getName()); } if (multipartEnabled) { S3Object object = s3Service.getObjectDetails(bucket, srcKey, null, null, null, null); if (multipartCopyBlockSize > 0 && object.getContentLength() > multipartCopyBlockSize) { copyLargeFile(object, dstKey); return; } } S3Object dstObject = new S3Object(dstKey); dstObject.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm); s3Service.copyObject(bucket.getName(), srcKey, bucket.getName(), dstObject, false); } catch (ServiceException e) { handleException(e, srcKey); } }
Example 5
Source File: S3WriteFeature.java From cyberduck with GNU General Public License v3.0 | 5 votes |
/** * Add default metadata */ protected S3Object getDetails(final Path file, final TransferStatus status) { final S3Object object = new S3Object(containerService.getKey(file)); final String mime = status.getMime(); if(StringUtils.isNotBlank(mime)) { object.setContentType(mime); } final Checksum checksum = status.getChecksum(); if(Checksum.NONE != checksum) { switch(checksum.algorithm) { case md5: object.setMd5Hash(ServiceUtils.fromHex(checksum.hash)); break; case sha256: object.addMetadata("x-amz-content-sha256", checksum.hash); break; } } if(StringUtils.isNotBlank(status.getStorageClass())) { if(!S3Object.STORAGE_CLASS_STANDARD.equals(status.getStorageClass())) { // The default setting is STANDARD. object.setStorageClass(status.getStorageClass()); } } final Encryption.Algorithm encryption = status.getEncryption(); object.setServerSideEncryptionAlgorithm(encryption.algorithm); // If the x-amz-server-side-encryption is present and has the value of aws:kms, this header specifies the ID of the // AWS Key Management Service (KMS) master encryption key that was used for the object. object.setServerSideEncryptionKmsKeyId(encryption.key); for(Map.Entry<String, String> m : status.getMetadata().entrySet()) { object.addMetadata(m.getKey(), m.getValue()); } return object; }
Example 6
Source File: Jets3tNativeFileSystemStore.java From hadoop with Apache License 2.0 | 5 votes |
@Override public void storeEmptyFile(String key) throws IOException { try { S3Object object = new S3Object(key); object.setDataInputStream(new ByteArrayInputStream(new byte[0])); object.setContentType("binary/octet-stream"); object.setContentLength(0); object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm); s3Service.putObject(bucket, object); } catch (ServiceException e) { handleException(e, key); } }
Example 7
Source File: Jets3tNativeFileSystemStore.java From big-c with Apache License 2.0 | 5 votes |
@Override public void storeEmptyFile(String key) throws IOException { try { S3Object object = new S3Object(key); object.setDataInputStream(new ByteArrayInputStream(new byte[0])); object.setContentType("binary/octet-stream"); object.setContentLength(0); object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm); s3Service.putObject(bucket, object); } catch (ServiceException e) { handleException(e, key); } }