Analogue of IBM COS ListObjectsV2 on Azure Blob Storage

99 Views Asked by At

Good day. I've the following code snippet for interacting with IBM Cloud Storage in Java:

ListObjectsV2Request request = new ListObjectsV2Request()
    .withBucketName(bucket)
    .withPrefix(prefix)
    .withMaxKey(keyCount)
    .withContinuationToken(token)
    .withSdkClientExecutionTimeut(timeout);
ListObjectsV2Result result = cosConfig.getClient().listObjectsV2(request);
result.getObjectSummaries()
    .stream()
    .filter(e -> e.getKey().endsWith(extension))
    .forEach(e -> map.put(
        e.getKey().substring(e.getKey().lastIndexOf("/") + 1),
        e.getETag()
    ));
if (result.isTruncated()) {
    token = result.getNextContinuationToken();
}

But can't find exact alternative on Azure Blob. Do I understand correctly that it's easier to get a container and then find the necessary ones in the list of blobs?

Thanks a lot

1

There are 1 best solutions below

0
On BEST ANSWER

Do I understand correctly that it's easier to get a container and then find the necessary ones in the list of blobs?

Yes, that's correct. This is the exact hierarchy of Azure Blob Storage.

Azure Blob Storage is optimized for storing massive amounts of unstructured data. Unstructured data is data that does not adhere to a particular data model or definition, such as text or binary data. Blob storage offers three types of resources:

  • The storage account
  • A container in the storage account
  • A blob in the container

enter image description here

Java v12 SDK allows you to interact with Containers and Blobs. This SDK provides classes to interact with these resources:

  • BlobServiceClient: The BlobServiceClient class allows you to manipulate Azure Storage resources and blob containers. The storage account provides the top-level namespace for the Blob service.
  • BlobServiceClientBuilder: The BlobServiceClientBuilder class provides a fluent builder API to help aid the configuration and instantiation of BlobServiceClient objects.
  • BlobContainerClient: The BlobContainerClient class allows you to manipulate Azure Storage containers and their blobs.
  • BlobClient: The BlobClient class allows you to manipulate Azure Storage blobs.
  • BlobItem: The BlobItem class represents individual blobs returned from a call to listBlobs.

For code example to work with these classes, please visit here.