当前位置: 首页>>代码示例>>Java>>正文


Java CopyObjectResult类代码示例

本文整理汇总了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
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:MockAmazonS3.java

示例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()));
}
 
开发者ID:adobe,项目名称:S3Mock,代码行数:32,代码来源:AmazonClientUploadIT.java

示例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;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:8,代码来源:AmazonS3ClientMock.java

示例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));
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:8,代码来源:AmazonS3Client.java

示例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;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:21,代码来源:CopyCallable.java

示例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());
    }
}
 
开发者ID:blacklabelops,项目名称:backuprotator,代码行数:28,代码来源:AWSHandler.java

示例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();
    }
}
 
开发者ID:Talend,项目名称:daikon,代码行数:12,代码来源:S3DeletableResource.java

示例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;
}
 
开发者ID:dgks0n,项目名称:milton-aws,代码行数:32,代码来源:AmazonS3ManagerImpl.java

示例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()));
    }
    
}
 
开发者ID:bitsofinfo,项目名称:s3-bucket-loader,代码行数:34,代码来源:S3KeyCopyingTOCPayloadHandler.java

示例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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonS3Wrapper.java

示例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));
}
 
开发者ID:HubSpot,项目名称:S3Decorators,代码行数:5,代码来源:S3Decorator.java

示例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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:AmazonS3ClientMock.java

示例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;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:7,代码来源:MockAmazonS3.java

示例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;
}
 
开发者ID:DemandCube,项目名称:Scribengin,代码行数:7,代码来源:AmazonS3Mock.java

示例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);
                    }
                }
            });
        }
    }
 
开发者ID:scoyo,项目名称:S3-CacheEnhancer,代码行数:47,代码来源:S3HeaderEnhancer.java


注:本文中的com.amazonaws.services.s3.model.CopyObjectResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。