|
|
@ -5,6 +5,8 @@ import com.amazonaws.auth.BasicAWSCredentials; |
|
|
|
import com.amazonaws.client.builder.AwsClientBuilder; |
|
|
|
import com.amazonaws.client.builder.AwsClientBuilder; |
|
|
|
import com.amazonaws.services.s3.AmazonS3; |
|
|
|
import com.amazonaws.services.s3.AmazonS3; |
|
|
|
import com.amazonaws.services.s3.AmazonS3ClientBuilder; |
|
|
|
import com.amazonaws.services.s3.AmazonS3ClientBuilder; |
|
|
|
|
|
|
|
import com.amazonaws.services.s3.model.CopyObjectRequest; |
|
|
|
|
|
|
|
import com.amazonaws.services.s3.model.DeleteObjectRequest; |
|
|
|
import com.amazonaws.services.s3.model.GetObjectRequest; |
|
|
|
import com.amazonaws.services.s3.model.GetObjectRequest; |
|
|
|
import com.amazonaws.services.s3.model.ListObjectsRequest; |
|
|
|
import com.amazonaws.services.s3.model.ListObjectsRequest; |
|
|
|
import com.amazonaws.services.s3.model.ObjectListing; |
|
|
|
import com.amazonaws.services.s3.model.ObjectListing; |
|
|
@ -71,8 +73,10 @@ public class S3ResourceRepository extends BaseResourceRepository { |
|
|
|
ObjectListing objectListing = s3.listObjects(listObjectsRequest); |
|
|
|
ObjectListing objectListing = s3.listObjects(listObjectsRequest); |
|
|
|
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) { |
|
|
|
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) { |
|
|
|
String key = summary.getKey(); |
|
|
|
String key = summary.getKey(); |
|
|
|
|
|
|
|
if (!key.endsWith(DELIMITER)) { |
|
|
|
result.add(s3Object2FileEntry(summary, key)); |
|
|
|
result.add(s3Object2FileEntry(summary, key)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
for (String prefix : objectListing.getCommonPrefixes()) { |
|
|
|
for (String prefix : objectListing.getCommonPrefixes()) { |
|
|
|
FineFileEntry entry = new FineFileEntry(prefix); |
|
|
|
FineFileEntry entry = new FineFileEntry(prefix); |
|
|
|
entry.setDirectory(true); |
|
|
|
entry.setDirectory(true); |
|
|
@ -224,6 +228,20 @@ public class S3ResourceRepository extends BaseResourceRepository { |
|
|
|
return s3Object.getObjectMetadata().getContentLength(); |
|
|
|
return s3Object.getObjectMetadata().getContentLength(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean rename(String path, String newPath) throws ResourceIOException { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
CopyObjectRequest copyObjRequest = new CopyObjectRequest(bucket, |
|
|
|
|
|
|
|
path, bucket, newPath); |
|
|
|
|
|
|
|
s3.copyObject(copyObjRequest); |
|
|
|
|
|
|
|
s3.deleteObject(new DeleteObjectRequest(bucket, path)); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
LogKit.error(e.getMessage(), e); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void shutDown() { |
|
|
|
public void shutDown() { |
|
|
|
s3.shutdown(); |
|
|
|
s3.shutdown(); |
|
|
@ -233,4 +251,5 @@ public class S3ResourceRepository extends BaseResourceRepository { |
|
|
|
public String getIdentity() { |
|
|
|
public String getIdentity() { |
|
|
|
return S3RepositoryFactory.IDENTITY; |
|
|
|
return S3RepositoryFactory.IDENTITY; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|