Apache jclouds, best way to delete blob from blobstore older than a date

413 views Asked by At

Hi I try to implement a method removeValuesUnusedLongerThan(long minimumAge, TimeUnit unit) that mean I want to delete every unused blob older than minimumAge inside my S3 container. But I don't find which method to use in my BlobStore object to achieve this.

Does JClouds provide a such feature ?

1

There are 1 answers

0
Andrew Gaul On BEST ANSWER

jclouds does not provide a utility method for this but you can roll your own:

String marker = null;
while (true) {
    PageSet<StorageMetadata> set = blobStore.list(containerName,
            new ListContainerOptions().afterMarker(marker);
    for (StorageMetadata sm : set) {
        if (sm.getCreateDate() < expiryDate) {
            blobStore.removeBlob(containerName, sm.getName());
        }
    }
    marker = set.getNextMarker();
    if (marker == null) {
        break;
    }
}