Java 类com.amazonaws.services.s3.model.CopyObjectResult 实例源码

项目:elasticsearch_my    文件:MockAmazonS3.java   
@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
}
项目:S3Mock    文件:AmazonClientUploadIT.java   
/**
 * 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()));
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws AmazonClientException, AmazonServiceException {
    CopyObjectResult copyObjectResult = new CopyObjectResult();
    copyObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264");
    copyObjectResult.setVersionId("11192828ahsh2723");
    return copyObjectResult;
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws AmazonClientException, AmazonServiceException {
    CopyObjectResult copyObjectResult = new CopyObjectResult();
    copyObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264");
    copyObjectResult.setVersionId("11192828ahsh2723");
    return copyObjectResult;
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws AmazonClientException, AmazonServiceException {
    CopyObjectResult copyObjectResult = new CopyObjectResult();
    copyObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264");
    copyObjectResult.setVersionId("11192828ahsh2723");
    return copyObjectResult;
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws AmazonClientException, AmazonServiceException {
    CopyObjectResult copyObjectResult = new CopyObjectResult();
    copyObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264");
    copyObjectResult.setVersionId("11192828ahsh2723");
    return copyObjectResult;
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws AmazonClientException, AmazonServiceException {
    CopyObjectResult copyObjectResult = new CopyObjectResult();
    copyObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264");
    copyObjectResult.setVersionId("11192828ahsh2723");
    return copyObjectResult;
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws AmazonClientException, AmazonServiceException {
    CopyObjectResult copyObjectResult = new CopyObjectResult();
    copyObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264");
    copyObjectResult.setVersionId("11192828ahsh2723");
    return copyObjectResult;
}
项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey,
                                   String destinationBucketName, String destinationKey)
        throws SdkClientException, AmazonServiceException {
    return copyObject(new CopyObjectRequest(sourceBucketName, sourceKey,
                                            destinationBucketName, destinationKey));
}
项目:ibm-cos-sdk-java    文件:CopyCallable.java   
/**
 * 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;
}
项目:backuprotator    文件:AWSHandler.java   
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());
    }
}
项目:daikon    文件:S3DeletableResource.java   
@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();
    }
}
项目:milton-aws    文件:AmazonS3ManagerImpl.java   
@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;
}
项目:s3-bucket-loader    文件:S3KeyCopyingTOCPayloadHandler.java   
@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()));
    }

}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException {
    return delegate.copyObject(sourceBucketName, sourceKey, destinationBucketName, destinationKey);
}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws AmazonClientException, AmazonServiceException {
    return delegate.copyObject(copyObjectRequest);
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws SdkClientException, AmazonServiceException {
  return call(() -> getDelegate().copyObject(sourceBucketName, sourceKey, destinationBucketName, destinationKey));
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws SdkClientException, AmazonServiceException {
  return call(() -> getDelegate().copyObject(copyObjectRequest));
}
项目:Camel    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:Camel    文件:AmazonS3ClientMock.java   
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:presto    文件:MockAmazonS3.java   
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey)
        throws AmazonClientException
{
    return null;
}
项目:presto    文件:MockAmazonS3.java   
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest)
        throws AmazonClientException
{
    return null;
}
项目:Scribengin    文件:AmazonS3Mock.java   
@Override
public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName,
    String destinationKey) throws AmazonClientException, AmazonServiceException {
  // TODO Auto-generated method stub
  return null;
}
项目:Scribengin    文件:AmazonS3Mock.java   
@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws AmazonClientException,
    AmazonServiceException {
  // TODO Auto-generated method stub
  return null;
}
项目:S3-CacheEnhancer    文件:S3HeaderEnhancer.java   
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);
                    }
                }
            });
        }
    }