本文整理汇总了Java中org.jets3t.service.model.S3Object.setServerSideEncryptionAlgorithm方法的典型用法代码示例。如果您正苦于以下问题:Java S3Object.setServerSideEncryptionAlgorithm方法的具体用法?Java S3Object.setServerSideEncryptionAlgorithm怎么用?Java S3Object.setServerSideEncryptionAlgorithm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jets3t.service.model.S3Object
的用法示例。
在下文中一共展示了S3Object.setServerSideEncryptionAlgorithm方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: storeLargeFile
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
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);
}
}
示例2: copy
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@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);
}
}
示例3: getDetails
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
/**
* 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;
}
示例4: storeEmptyFile
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@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);
}
}
示例5: storeFile
import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public void storeFile(String key, File file, byte[] md5Hash)
throws IOException {
if (multipartEnabled && file.length() >= multipartBlockSize) {
storeLargeFile(key, file, md5Hash);
return;
}
BufferedInputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(file));
S3Object object = new S3Object(key);
object.setDataInputStream(in);
object.setContentType("binary/octet-stream");
object.setContentLength(file.length());
object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm);
if (md5Hash != null) {
object.setMd5Hash(md5Hash);
}
s3Service.putObject(bucket, object);
} catch (ServiceException e) {
handleException(e, key);
} finally {
IOUtils.closeStream(in);
}
}