javarackspace-cloudrackspacejcloudsrackspace-cloudfiles

Rackspace Cloud Files (using jclouds) - how to get container location


I use jclouds as an api for Rackspace Cloud Files.

Api allows me to create containers in different locations using BlobStore.createContainerInLocation

Now, having container that is already exists, how do I get it's location?


Solution

  • jclouds does not provide a direct mechanism for this. Instead you can call BlobStore.list, compare the container names, then consume StorageMetadata.getLocation:

    for (StorageMetadata resourceMd : blobStore.list()) {
        if (containerName.equals(resourceMd.getName())) {
            System.out.println(resourceMd.getLocation().getId());
        }
    }