I have a camel route to list all blobs in azure blobstorage. But the exchange body does not has a list of BlobItem but BlobContainerItem resulting in a ClassCastException with my code
ClassCastException: class com.azure.storage.blob.models.BlobContainerItem cannot be cast to class com.azure.storage.blob.models.BlobItem
from("timer://listAllBlobs?fixedRate=true&period=1s")
.to("azure-storage-blob://devstoreaccount1/hotfolder&serviceClient=#blobServiceClient&operation=listBlobs")
.tracing()
.process(exchange -> {
ArrayList<BlobItem> items = exchange.getIn().getBody(ArrayList.class);
for (BlobItem blobItem : items) {
System.out.println(blobItem.getName());
}
});
With
ArrayList<BlobContainerItem> items = exchange.getIn().getBody(ArrayList.class);
for (BlobContainerItem blobItem : items) {
System.out.println(blobItem.getName());
}
I get the output hotfolder. But that are not the files in it but the container itself.
How to iterate over the blobs correctly?