本文整理汇总了Java中com.amazonaws.services.s3.model.CopyObjectRequest.setNewObjectMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java CopyObjectRequest.setNewObjectMetadata方法的具体用法?Java CopyObjectRequest.setNewObjectMetadata怎么用?Java CopyObjectRequest.setNewObjectMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.model.CopyObjectRequest
的用法示例。
在下文中一共展示了CopyObjectRequest.setNewObjectMetadata方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: move
import com.amazonaws.services.s3.model.CopyObjectRequest; //导入方法依赖的package包/类
@Override
public void move(String sourceBlobName, String targetBlobName) throws IOException {
try {
CopyObjectRequest request = new CopyObjectRequest(blobStore.bucket(), buildKey(sourceBlobName),
blobStore.bucket(), buildKey(targetBlobName));
if (blobStore.serverSideEncryption()) {
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
request.setNewObjectMetadata(objectMetadata);
}
SocketAccess.doPrivilegedVoid(() -> {
blobStore.client().copyObject(request);
blobStore.client().deleteObject(blobStore.bucket(), buildKey(sourceBlobName));
});
} catch (AmazonS3Exception e) {
throw new IOException(e);
}
}
示例2: storeMimeType
import com.amazonaws.services.s3.model.CopyObjectRequest; //导入方法依赖的package包/类
@Override
protected void storeMimeType(BinaryValue binaryValue, String mimeType)
throws BinaryStoreException {
try {
String key = binaryValue.getKey().toString();
ObjectMetadata metadata = s3Client.getObjectMetadata(bucketName, key);
metadata.setContentType(mimeType);
// Update the object in place
CopyObjectRequest copyRequest =
new CopyObjectRequest(bucketName, key, bucketName, key);
copyRequest.setNewObjectMetadata(metadata);
s3Client.copyObject(copyRequest);
} catch (AmazonClientException e) {
throw new BinaryStoreException(e);
}
}
示例3: setS3ObjectUserProperty
import com.amazonaws.services.s3.model.CopyObjectRequest; //导入方法依赖的package包/类
private void setS3ObjectUserProperty(BinaryKey binaryKey,
String metadataKey,
String metadataValue)
throws BinaryStoreException {
try {
String key = binaryKey.toString();
ObjectMetadata metadata = s3Client.getObjectMetadata(bucketName, key);
Map<String, String> userMetadata = metadata.getUserMetadata();
if(null != metadataValue &&
metadataValue.equals(userMetadata.get(metadataKey))) {
return; // The key/value pair already exists in user metadata, skip update
}
userMetadata.put(metadataKey, metadataValue);
metadata.setUserMetadata(userMetadata);
// Update the object in place
CopyObjectRequest copyRequest =
new CopyObjectRequest(bucketName, key, bucketName, key);
copyRequest.setNewObjectMetadata(metadata);
s3Client.copyObject(copyRequest);
} catch (AmazonClientException e) {
throw new BinaryStoreException(e);
}
}
示例4: copyFile
import com.amazonaws.services.s3.model.CopyObjectRequest; //导入方法依赖的package包/类
private void copyFile(String srcKey, String dstKey) throws IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("copyFile " + srcKey + " -> " + dstKey);
}
ObjectMetadata srcom = s3.getObjectMetadata(bucket, srcKey);
final ObjectMetadata dstom = srcom.clone();
if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
dstom.setServerSideEncryption(serverSideEncryptionAlgorithm);
}
CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucket, srcKey, bucket, dstKey);
copyObjectRequest.setCannedAccessControlList(cannedACL);
copyObjectRequest.setNewObjectMetadata(dstom);
ProgressListener progressListener = new ProgressListener() {
public void progressChanged(ProgressEvent progressEvent) {
switch (progressEvent.getEventCode()) {
case ProgressEvent.PART_COMPLETED_EVENT_CODE:
statistics.incrementWriteOps(1);
break;
default:
break;
}
}
};
Copy copy = transfers.copy(copyObjectRequest);
copy.addProgressListener(progressListener);
try {
copy.waitForCopyResult();
statistics.incrementWriteOps(1);
} catch (InterruptedException e) {
throw new IOException("Got interrupted, cancelling");
}
}
示例5: copyFile
import com.amazonaws.services.s3.model.CopyObjectRequest; //导入方法依赖的package包/类
private void copyFile(String srcKey, String dstKey) throws IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("copyFile " + srcKey + " -> " + dstKey);
}
ObjectMetadata srcom = s3.getObjectMetadata(bucket, srcKey);
final ObjectMetadata dstom = srcom.clone();
if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
dstom.setSSEAlgorithm(serverSideEncryptionAlgorithm);
}
CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucket, srcKey, bucket, dstKey);
copyObjectRequest.setCannedAccessControlList(cannedACL);
copyObjectRequest.setNewObjectMetadata(dstom);
ProgressListener progressListener = new ProgressListener() {
public void progressChanged(ProgressEvent progressEvent) {
switch (progressEvent.getEventType()) {
case TRANSFER_PART_COMPLETED_EVENT:
statistics.incrementWriteOps(1);
break;
default:
break;
}
}
};
Copy copy = transfers.copy(copyObjectRequest);
copy.addProgressListener(progressListener);
try {
copy.waitForCopyResult();
statistics.incrementWriteOps(1);
} catch (InterruptedException e) {
throw new IOException("Got interrupted, cancelling");
}
}
示例6: copyFile
import com.amazonaws.services.s3.model.CopyObjectRequest; //导入方法依赖的package包/类
private void copyFile(String srcKey, String dstKey) throws IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("copyFile " + srcKey + " -> " + dstKey);
}
ObjectMetadata srcom = s3.getObjectMetadata(bucket, srcKey);
final ObjectMetadata dstom = srcom.clone();
if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
dstom.setServerSideEncryption(serverSideEncryptionAlgorithm);
}
CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucket, srcKey, bucket, dstKey);
copyObjectRequest.setCannedAccessControlList(cannedACL);
copyObjectRequest.setNewObjectMetadata(dstom);
ProgressListener progressListener = new ProgressListener() {
public void progressChanged(ProgressEvent progressEvent) {
switch (progressEvent.getEventCode()) {
case ProgressEvent.PART_COMPLETED_EVENT_CODE:
statistics.incrementWriteOps(1);
break;
}
}
};
Copy copy = transfers.copy(copyObjectRequest);
copy.addProgressListener(progressListener);
try {
copy.waitForCopyResult();
statistics.incrementWriteOps(1);
} catch (InterruptedException e) {
throw new IOException("Got interrupted, cancelling");
}
}