List of usage examples for com.amazonaws.services.s3.model S3Object getRedirectLocation
public String getRedirectLocation()
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 ww w . j ava 2 s.c o m 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.openflamingo.fs.s3.S3Utils.java
License:Apache License
/** * Object ./*from www . j a va 2 s . c o m*/ * * @param client Amazon S3 Client * @param bucketName Bucket Name */ public static Map<String, String> getObject(AmazonS3Client client, String bucketName, String objectKey) { S3Object object = client.getObject(bucketName, objectKey); ObjectMetadata objectMetadata = object.getObjectMetadata(); Map<String, String> map = new HashMap<String, String>(); if (!object.getKey().endsWith("/")) { String qualifiedPath = "/" + bucketName + "/" + object.getKey(); map.put("bucketName", object.getBucketName()); map.put("name", FileUtils.getFilename(qualifiedPath)); map.put("path", qualifiedPath); } else { map.put("bucketName", object.getBucketName()); map.put("name", object.getKey()); map.put("name", "/" + bucketName + "/" + object.getKey()); } setValue("redirectionLocation", object.getRedirectLocation(), map); setValue("version", objectMetadata.getVersionId(), map); setValue("contentDisposition", objectMetadata.getContentDisposition(), map); setValue("contentType", objectMetadata.getContentType(), map); setValue("etag", objectMetadata.getETag(), map); setValue("contentEncoding", objectMetadata.getContentEncoding(), map); setValue("contentLength", objectMetadata.getContentLength(), map); setValue("lastModified", objectMetadata.getLastModified(), map); return map; }
From source file:org.openflamingo.fs.s3.S3Utils.java
License:Apache License
/** * Object .//w w w .j av a 2 s .c o m * * @param client Amazon S3 Client * @param bucketName Bucket Name */ public static Map<String, String> getDirectory(AmazonS3Client client, String bucketName, String objectKey) { S3Object object = client.getObject(bucketName, objectKey); ObjectMetadata objectMetadata = object.getObjectMetadata(); List<FileInfo> filesList = new ArrayList<FileInfo>(); ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(object.getBucketName()) .withPrefix(objectKey).withDelimiter("/"); ObjectListing objectListing = null; do { objectListing = client.listObjects(listObjectsRequest); List<String> commonPrefixes = objectListing.getCommonPrefixes(); List<S3ObjectSummary> summary = objectListing.getObjectSummaries(); listObjectsRequest.setMarker(objectListing.getNextMarker()); } while (objectListing.isTruncated()); Map<String, String> map = new HashMap<String, String>(); map.put("bucketName", object.getBucketName()); map.put("name", object.getKey()); map.put("redirectionLocation", object.getRedirectLocation()); setValue("version", objectMetadata.getVersionId(), map); setValue("contentDisposition", objectMetadata.getContentDisposition(), map); setValue("contentType", objectMetadata.getContentType(), map); setValue("etag", objectMetadata.getETag(), map); setValue("contentEncoding", objectMetadata.getContentEncoding(), map); setValue("contentLength", objectMetadata.getContentLength(), map); setValue("lastModified", objectMetadata.getLastModified(), map); return null; }
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 . j a v a2 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"); }