List of usage examples for com.amazonaws.services.s3.model S3Object setRedirectLocation
public void setRedirectLocation(String redirectLocation)
From source file:com.upplication.s3fs.util.AmazonS3ClientMock.java
License:Open Source License
@Override public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException { S3Element element = find(sourceBucketName, sourceKey); if (element != null) { S3Object objectSource = element.getS3Object(); // copy object with S3Object resObj = new S3Object(); resObj.setBucketName(destinationBucketName); resObj.setKey(destinationKey);/*from w w w . j a v a2 s .com*/ resObj.setObjectContent(objectSource.getObjectContent()); resObj.setObjectMetadata(objectSource.getObjectMetadata()); resObj.setRedirectLocation(objectSource.getRedirectLocation()); // copy permission AccessControlList permission = new AccessControlList(); permission.setOwner(element.getPermission().getOwner()); permission.grantAllPermissions(element.getPermission().getGrants().toArray(new Grant[0])); S3Element elementResult = new S3Element(resObj, permission, sourceKey.endsWith("/")); // TODO: add should replace existing objects.get(find(destinationBucketName)).remove(elementResult); objects.get(find(destinationBucketName)).add(elementResult); return new CopyObjectResult(); } throw new AmazonServiceException("object source not found"); }
From source file:org.weakref.s3fs.util.AmazonS3ClientMock.java
License:Apache License
@Override public CopyObjectResult copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey) throws AmazonClientException, AmazonServiceException { S3Element element = find(sourceBucketName, sourceKey); if (element != null) { S3Object objectSource = element.getS3Object(); // copy object with S3Object resObj = new S3Object(); resObj.setBucketName(destinationBucketName); resObj.setKey(destinationKey);/* w w w.ja va 2 s . co m*/ resObj.setObjectContent(objectSource.getObjectContent()); resObj.setObjectMetadata(objectSource.getObjectMetadata()); resObj.setRedirectLocation(objectSource.getRedirectLocation()); // copy perission AccessControlList permission = new AccessControlList(); permission.setOwner(element.getPermission().getOwner()); permission.grantAllPermissions(element.getPermission().getGrants().toArray(new Grant[0])); // maybe not exists key TODO objects.get(find(destinationBucketName)) .add(new S3Element(resObj, permission, sourceKey.endsWith("/"))); return new CopyObjectResult(); } throw new AmazonServiceException("object source not found"); }