@Override public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws SdkClientException, AmazonServiceException { return copyObject(new CopyObjectRequest(sourceBucketName, sourceKey, destinationBucketName, destinationKey)); }
@Override public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws SdkClientException, AmazonServiceException { return copyObject(new CopyObjectRequest(sourceBucketName, sourceKey, destinationBucketName, destinationKey)); }
String destinationBucketName, String destinationKey) throws AmazonServiceException, AmazonClientException { return copy(new CopyObjectRequest(sourceBucketName, sourceKey, destinationBucketName, destinationKey));
@Override protected boolean copyObject(String src, String dst) { LOG.debug("Copying {} to {}", src, dst); // Retry copy for a few times, in case some AWS internal errors happened during copy. int retries = 3; for (int i = 0; i < retries; i++) { try { CopyObjectRequest request = new CopyObjectRequest(mBucketName, src, mBucketName, dst); if (Boolean.parseBoolean( mConf.get(PropertyKey.UNDERFS_S3A_SERVER_SIDE_ENCRYPTION_ENABLED))) { ObjectMetadata meta = new ObjectMetadata(); meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); request.setNewObjectMetadata(meta); } mManager.copy(request).waitForCopyResult(); return true; } catch (AmazonClientException | InterruptedException e) { LOG.error("Failed to copy file {} to {}", src, dst, e); if (i != retries - 1) { LOG.error("Retrying copying file {} to {}", src, dst); } } } LOG.error("Failed to copy file {} to {}, after {} retries", src, dst, retries); return false; }
@Override public void setObjectRedirectLocation(String bucketName, String key, String newRedirectLocation) throws SdkClientException, AmazonServiceException { rejectNull(bucketName, "The bucketName parameter must be specified when changing an object's storage class"); rejectNull(key, "The key parameter must be specified when changing an object's storage class"); rejectNull(newRedirectLocation, "The newStorageClass parameter must be specified when changing an object's storage class"); copyObject(new CopyObjectRequest(bucketName, key, bucketName, key) .withRedirectLocation(newRedirectLocation)); }
@Override public void changeObjectStorageClass(String bucketName, String key, StorageClass newStorageClass) throws SdkClientException, AmazonServiceException { rejectNull(bucketName, "The bucketName parameter must be specified when changing an object's storage class"); rejectNull(key, "The key parameter must be specified when changing an object's storage class"); rejectNull(newStorageClass, "The newStorageClass parameter must be specified when changing an object's storage class"); copyObject(new CopyObjectRequest(bucketName, key, bucketName, key) .withStorageClass(newStorageClass.toString())); }
} else { log.info("Moving file %s", copyMsg); final CopyObjectRequest copyRequest = new CopyObjectRequest(s3Bucket, s3Path, targetS3Bucket, targetS3Path); if (!config.getDisableAcl()) { copyRequest.setAccessControlList(S3Utils.grantFullControlToBucketOwner(s3Client, targetS3Bucket));
@Override public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException { return copyObject(new CopyObjectRequest(sourceBucketName, sourceKey, destinationBucketName, destinationKey)); }
String destinationBucketName, String destinationKey) throws AmazonServiceException, AmazonClientException { return copy(new CopyObjectRequest(sourceBucketName, sourceKey, destinationBucketName, destinationKey));
@Override public void setObjectRedirectLocation(String bucketName, String key, String newRedirectLocation) throws AmazonClientException, AmazonServiceException { assertParameterNotNull(bucketName, "The bucketName parameter must be specified when changing an object's storage class"); assertParameterNotNull(key, "The key parameter must be specified when changing an object's storage class"); assertParameterNotNull(newRedirectLocation, "The newStorageClass parameter must be specified when changing an object's storage class"); copyObject(new CopyObjectRequest(bucketName, key, bucketName, key) .withRedirectLocation(newRedirectLocation)); }
@Override public void changeObjectStorageClass(String bucketName, String key, StorageClass newStorageClass) throws AmazonClientException, AmazonServiceException { assertParameterNotNull(bucketName, "The bucketName parameter must be specified when changing an object's storage class"); assertParameterNotNull(key, "The key parameter must be specified when changing an object's storage class"); assertParameterNotNull(newStorageClass, "The newStorageClass parameter must be specified when changing an object's storage class"); copyObject(new CopyObjectRequest(bucketName, key, bucketName, key) .withStorageClass(newStorageClass.toString())); }
static AmazonS3 client; client = Amazon.AWSClientFactory.CreateAmazonS3Client( accessKeyID, secretAccessKeyID); CopyObjectRequest request = new CopyObjectRequest(); request.SourceBucket = bucketName; request.SourceKey = keyName; request.DestinationBucket = bucketName; request.DestinationKey = destKeyName; S3Response response = client.CopyObject(request);
@Override public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException { return copyObject(new CopyObjectRequest(sourceBucketName, sourceKey, destinationBucketName, destinationKey)); }
@Override public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws SdkClientException, AmazonServiceException { return copyObject(new CopyObjectRequest(sourceBucketName, sourceKey, destinationBucketName, destinationKey)); }
@Override public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws SdkClientException, AmazonServiceException { return copyObject(new CopyObjectRequest(sourceBucketName, sourceKey, destinationBucketName, destinationKey)); }
@Override public void backupAsAux(String auxItemTag) throws IOException { String destinationKey = getDestinationKey(auxItemTag); try { s3.copyObject(new CopyObjectRequest(bucketName, key, bucketName, destinationKey)); } catch (AmazonClientException ase) { logger.warning("Caught an AmazonClientException in S3AccessIO.backupAsAux: " + ase.getMessage()); throw new IOException("S3AccessIO: Unable to backup original auxiliary object"); } }
@Override public void revertBackupAsAux(String auxItemTag) throws IOException { String destinationKey = getDestinationKey(auxItemTag); try { s3.copyObject(new CopyObjectRequest(bucketName, destinationKey, bucketName, key)); deleteAuxObject(auxItemTag); } catch (AmazonClientException ase) { logger.warning("Caught an AmazonServiceException in S3AccessIO.backupAsAux: " + ase.getMessage()); throw new IOException("S3AccessIO: Unable to revert backup auxiliary object"); } }
@Override public void rename(String pathFrom, String pathTo) throws IOException { String[] bucketKeyFrom = splitPathToBucketAndKey(pathFrom, true); String[] bucketKeyTo = splitPathToBucketAndKey(pathTo, true); CopyObjectRequest copyRequest = new CopyObjectRequest(bucketKeyFrom[0], bucketKeyFrom[1], bucketKeyTo[0], bucketKeyTo[1]); this.amazonS3.copyObject(copyRequest); //Delete the source this.amazonS3.deleteObject(bucketKeyFrom[0], bucketKeyFrom[1]); }
@Override public FileData copyHistory(String srcName, FileData destData, String version) throws IOException { try { CopyObjectRequest request = new CopyObjectRequest(bucketName, srcName, version, bucketName, destData.getName()); CopyObjectResult result = s3.copyObject(request); onModified(); return checkHistory(destData.getName(), result.getVersionId()); } catch (SdkClientException e) { throw new IOException(e); } }
@Override public void setObjectRedirectLocation(String bucketName, String key, String newRedirectLocation) throws SdkClientException, AmazonServiceException { rejectNull(bucketName, "The bucketName parameter must be specified when changing an object's storage class"); rejectNull(key, "The key parameter must be specified when changing an object's storage class"); rejectNull(newRedirectLocation, "The newStorageClass parameter must be specified when changing an object's storage class"); copyObject(new CopyObjectRequest(bucketName, key, bucketName, key) .withRedirectLocation(newRedirectLocation)); }