本文整理汇总了Java中com.amazonaws.services.s3.model.CopyObjectResult类的典型用法代码示例。如果您正苦于以下问题:Java CopyObjectResult类的具体用法?Java CopyObjectResult怎么用?Java CopyObjectResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CopyObjectResult类属于com.amazonaws.services.s3.model包,在下文中一共展示了CopyObjectResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyObject
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest)
throws AmazonClientException, AmazonServiceException {
String sourceBlobName = copyObjectRequest.getSourceKey();
String targetBlobName = copyObjectRequest.getDestinationKey();
if (!blobs.containsKey(sourceBlobName)) {
throw new AmazonS3Exception("Source blob [" +
sourceBlobName + "] does not exist.");
}
if (blobs.containsKey(targetBlobName)) {
throw new AmazonS3Exception("Target blob [" +
targetBlobName + "] already exists.");
}
blobs.put(targetBlobName, blobs.get(sourceBlobName));
return new CopyObjectResult(); // nothing is done with it
}
示例2: shouldCopyObjectEncrypted
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
/**
* Puts an Object; Copies that object to a new bucket; Downloads the object from the new
* bucket; compares checksums
* of original and copied object
*
* @throws Exception if an Exception occurs
*/
@Test
public void shouldCopyObjectEncrypted() throws Exception {
final File uploadFile = new File(UPLOAD_FILE_NAME);
final String sourceKey = UPLOAD_FILE_NAME;
final String destinationBucketName = "destinationBucket";
final String destinationKey = "copyOf/" + sourceKey;
s3Client.putObject(new PutObjectRequest(BUCKET_NAME, sourceKey, uploadFile));
final CopyObjectRequest copyObjectRequest =
new CopyObjectRequest(BUCKET_NAME, sourceKey, destinationBucketName, destinationKey);
copyObjectRequest.setSSEAwsKeyManagementParams(new SSEAwsKeyManagementParams(TEST_ENC_KEYREF));
final CopyObjectResult copyObjectResult = s3Client.copyObject(copyObjectRequest);
final ObjectMetadata metadata =
s3Client.getObjectMetadata(destinationBucketName, destinationKey);
final InputStream uploadFileIS = new FileInputStream(uploadFile);
final String uploadHash = HashUtil.getDigest(TEST_ENC_KEYREF, uploadFileIS);
assertThat("ETag should match", copyObjectResult.getETag(), is(uploadHash));
assertThat("Files should have the same length", metadata.getContentLength(),
is(uploadFile.length()));
}
示例3: copyObject
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws AmazonClientException, AmazonServiceException {
CopyObjectResult copyObjectResult = new CopyObjectResult();
copyObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264");
copyObjectResult.setVersionId("11192828ahsh2723");
return copyObjectResult;
}
示例4: copyObject
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey,
String destinationBucketName, String destinationKey)
throws SdkClientException, AmazonServiceException {
return copyObject(new CopyObjectRequest(sourceBucketName, sourceKey,
destinationBucketName, destinationKey));
}
示例5: copyInOneChunk
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
/**
* Performs the copy of the Amazon S3 object from source bucket to
* destination bucket. The Amazon S3 object is copied to destination in one
* single request.
*
* @returns CopyResult response information from the server.
*/
private CopyResult copyInOneChunk() {
CopyObjectResult copyObjectResult = s3.copyObject(copyObjectRequest);
CopyResult copyResult = new CopyResult();
copyResult.setSourceBucketName(copyObjectRequest.getSourceBucketName());
copyResult.setSourceKey(copyObjectRequest.getSourceKey());
copyResult.setDestinationBucketName(copyObjectRequest
.getDestinationBucketName());
copyResult.setDestinationKey(copyObjectRequest.getDestinationKey());
copyResult.setETag(copyObjectResult.getETag());
copyResult.setVersionId(copyObjectResult.getVersionId());
return copyResult;
}
示例6: moveFile
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
public void moveFile(Bucket srcBucket, Bucket targetBucket, String fileName, Logbook log) {
log.addEntry(new FileMoveLogEntry(srcBucket, targetBucket, fileName));
ObjectMetadata metadata = getMetaData(srcBucket, fileName);
if (!simulation && isAccessibleStorageClass(metadata)) {
logger.trace("Not simulation , so moving files from {}/{} to {}", srcBucket.getName(), srcBucket.getPath(), targetBucket);
long size = getFileSize(metadata);
CopyObjectResult result = null;
if (size > FIVE_GB) {
logger.trace("Big file multi attachement copy chosen, file size {}", size);
CompleteMultipartUploadResult completeUploadResponse = copyMultipartFile(srcBucket, targetBucket,
fileName, size);
if (completeUploadResponse != null) {
s3Client.deleteObject(srcBucket.getName(), srcBucket.getPath() + SEPARATOR + fileName);
}
} else {
logger.trace("Small file movement chosen, file size {}", size);
result = s3Client.copyObject(srcBucket.getName(), srcBucket.getPath() + SEPARATOR + fileName,
targetBucket.getName(), targetBucket.getPath() + SEPARATOR + fileName);
if (result != null) {
s3Client.deleteObject(srcBucket.getName(), srcBucket.getPath() + SEPARATOR + fileName);
}
}
} else {
logger.trace("Simulation mode or wrong storage class, moving files from {} to {}", srcBucket.getPath(), targetBucket.getName());
}
}
示例7: move
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
@Override
public void move(String location) throws IOException {
final String moveLocation = builder().append(root).append(toS3Location(location)).build().substring(1);
final CopyObjectResult result = amazonS3.copyObject(new CopyObjectRequest(bucket, this.location, bucket, moveLocation));
if (result == null) {
LOGGER.error("Unable to move {} to {}", this.location, moveLocation);
} else {
LOGGER.info("Copied {} to {}, now deleting {}", this.location, moveLocation, this.location);
delete();
}
}
示例8: copyEntity
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
@Override
public boolean copyEntity(String sourceBucketName, String sourceKeyName, String destinationBucketName,
String destinationKeyName) {
// If target bucket name is null or empty, that mean copy inside current
// bucket.
if (StringUtils.isEmpty(destinationBucketName)) {
destinationBucketName = sourceBucketName;
}
LOG.info("Copies a source object " + sourceKeyName
+ " from a source bucket " + sourceBucketName
+ " to a new destination bucket " + destinationBucketName
+ " with specified key " + destinationKeyName + " in Amazon S3");
try {
CopyObjectRequest copyObjectRequest = new CopyObjectRequest(sourceBucketName, sourceKeyName,
destinationBucketName, destinationKeyName);
CopyObjectResult copyObjectResult = amazonS3Client.copyObject(copyObjectRequest);
if (copyObjectResult != null) {
LOG.info("A CopyObjectResult object containing the information returned by Amazon S3 about the newly created object: "
+ copyObjectResult);
return true;
}
} catch (AmazonServiceException ase) {
LOG.warn(ase.getMessage(), ase);
} catch (AmazonClientException ace) {
LOG.warn(ace.getMessage(), ace);
}
return false;
}
示例9: handlePayload
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
@Override
public void handlePayload(TOCPayload payload, WorkerState workerState) throws Exception {
TocInfo tocInfo = payload.tocInfo;
String logPrefix = "handlePayload() KeyCopy s3://" + this.sourceS3BucketName + "/" + tocInfo.path +
" => s3://" + this.targetS3BucketName +"/"+ tocInfo.path;
try {
CopyObjectRequest copyRequest = new CopyObjectRequest(this.sourceS3BucketName,
tocInfo.path,
this.targetS3BucketName,
tocInfo.path);
copyRequest.setStorageClass(storageClass);
// copyRequest.setGeneralProgressListener(this);
if (this.enableServerSideEncryption) {
copyRequest.putCustomRequestHeader("x-amz-server-side-encryption", "AES256");
}
CopyObjectResult copyResult = s3Client.copyObject(copyRequest);
logger.debug(logPrefix + " copied OK");
workerState.addTocPathWritten(new TocPathOpResult(payload.mode, true, tocInfo.path, "s3.copyKey", "OK"));
} catch(Exception e) {
logger.error(logPrefix + " unexpected ERROR: " + e.getMessage(),e);
workerState.addTocPathWriteFailure(
new TocPathOpResult(payload.mode, false, tocInfo.path, "s3.copyKey", logPrefix + " " + e.getMessage()));
}
}
示例10: copyObject
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException {
return delegate.copyObject(sourceBucketName, sourceKey, destinationBucketName, destinationKey);
}
示例11: copyObject
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws SdkClientException, AmazonServiceException {
return call(() -> getDelegate().copyObject(sourceBucketName, sourceKey, destinationBucketName, destinationKey));
}
示例12: copyObject
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException {
throw new UnsupportedOperationException();
}
示例13: copyObject
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey)
throws AmazonClientException
{
return null;
}
示例14: copyObject
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName,
String destinationKey) throws AmazonClientException, AmazonServiceException {
// TODO Auto-generated method stub
return null;
}
示例15: setHeaders
import com.amazonaws.services.s3.model.CopyObjectResult; //导入依赖的package包/类
private void setHeaders(ObjectListing listing, final String maxAgeHeader, ExecutorService executorService) {
for (final S3ObjectSummary summary : listing.getObjectSummaries()) {
executorService.submit(new Runnable() {
@Override
public void run() {
String bucket = summary.getBucketName();
String key = summary.getKey();
ObjectMetadata metadata = null;
try {
metadata = s3.getObjectMetadata(bucket, key);
} catch (AmazonS3Exception exception) {
System.out.println("Could not update " + key + " [" + exception.getMessage() + "]");
return;
}
if ("application/x-directory".equals(metadata.getContentType())) {
System.out.println("Skipping because content-type " + key);
return;
}
if (!maxAgeHeader.equals(metadata.getCacheControl())) {
metadata.setCacheControl(maxAgeHeader);
} else {
System.out.println("Skipping because header is already correct " + key);
return;
}
AccessControlList acl = s3.getObjectAcl(summary.getBucketName(), summary.getKey());
CopyObjectRequest copyReq = new CopyObjectRequest(bucket, key, bucket, key)
.withAccessControlList(acl)
.withNewObjectMetadata(metadata);
CopyObjectResult result = s3.copyObject(copyReq);
if (result != null) {
System.out.println("Updated " + key);
} else {
System.out.println("Could not update " + key);
}
}
});
}
}