Source:
public static void main(String[] args) throws IOException { if (args.length < PARAMETERS) throw new IllegalArgumentException(INVALID_SYNTAX); String provider = args[0]; checkArgument(contains(allKeys, provider), "provider %s not in supported list: %s", provider, allKeys); String identity = args[1]; String credential = args[2]; String containerName = args[3]; BlobStoreContext context = ContextBuilder.newBuilder(provider) .credentials(identity, credential) .buildView(BlobStoreContext.class); try { BlobStore blobStore = context.getBlobStore(); blobStore.createContainerInLocation(null, containerName); String blobName = "test"; ByteSource payload = ByteSource.wrap("testdata".getBytes(Charsets.UTF_8)); for (StorageMetadata resourceMd : blobStore.list()) { if (containerName.equals(resourceMd.getName())) { System.out.println(resourceMd); } } Blob blob = blobStore.blobBuilder(blobName) .payload(payload) .contentLength(payload.size()) .build(); blobStore.putBlob(containerName, blob); ApiMetadata apiMetadata = context.unwrap().getProviderMetadata().getApiMetadata(); Object object = null; if (apiMetadata instanceof S3ApiMetadata) { S3Client api = context.unwrapApi(S3Client.class); object = api.headObject(containerName, blobName); } else if (apiMetadata instanceof SwiftApiMetadata) { SwiftApi api = context.unwrapApi(SwiftApi.class); object = api.getObjectApi(containerName, blobName); } else if (apiMetadata instanceof AtmosApiMetadata) { AtmosClient api = context.unwrapApi(AtmosClient.class); object = api.headFile(containerName + "/" + blobName); } if (object != null) { System.out.println(object); } } finally { context.close(); System.exit(0); } }

Target:
public static void main(String[] args) throws IOException { if (args.length < PARAMETERS) throw new IllegalArgumentException(INVALID_SYNTAX); String provider = args[0]; checkArgument(contains(allKeys, provider), "provider %s not in supported list: %s", provider, allKeys); String identity = args[1]; String credential = args[2]; String containerName = args[3]; BlobStoreContext context = ContextBuilder.newBuilder(provider) .credentials(identity, credential) .buildView(BlobStoreContext.class); try { BlobStore blobStore = context.getBlobStore(); blobStore.createContainerInLocation(null, containerName); String blobName = "test"; ByteSource payload = ByteSource.wrap("testdata".getBytes(Charsets.UTF_8)); for (StorageMetadata resourceMd : blobStore.list()) { if (containerName.equals(resourceMd.getName())) { System.out.println(resourceMd); } } Blob blob = blobStore.blobBuilder(blobName) .payload(payload) .contentLength(payload.size()) .build(); blobStore.putBlob(containerName, blob); ApiMetadata apiMetadata = context.unwrap().getProviderMetadata().getApiMetadata(); Object object = null; if (apiMetadata instanceof S3ApiMetadata) { S3Client api = context.unwrapApi(S3Client.class); object = api.headObject(containerName, blobName); } else if (apiMetadata instanceof SwiftApiMetadata) { SwiftApi api = context.unwrapApi(SwiftApi.class); object = api.getObjectApi(containerName, blobName); } else if (apiMetadata instanceof AzureBlobApiMetadata) { AzureBlobClient api = context.unwrapApi(AzureBlobClient.class); object = api.getBlobProperties(containerName, blobName); } else if (apiMetadata instanceof AtmosApiMetadata) { AtmosClient api = context.unwrapApi(AtmosClient.class); object = api.headFile(containerName + "/" + blobName); } if (object != null) { System.out.println(object); } } finally { context.close(); System.exit(0); } }