stijn192 commented on a change in pull request #4430:
URL: https://github.com/apache/nifi/pull/4430#discussion_r475587319
##########
File path:
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/ListAzureBlobStorage.java
##########
@@ -176,45 +174,38 @@ protected String getDefaultTimePrecision() {
protected List<BlobInfo> performListing(final ProcessContext context,
final Long minTimestamp) throws IOException {
String containerName =
context.getProperty(AzureStorageUtils.CONTAINER).evaluateAttributeExpressions().getValue();
String prefix =
context.getProperty(PROP_PREFIX).evaluateAttributeExpressions().getValue();
- if (prefix == null) {
- prefix = "";
- }
+
final List<BlobInfo> listing = new ArrayList<>();
try {
- CloudBlobClient blobClient =
AzureStorageUtils.createCloudBlobClient(context, getLogger(), null);
- CloudBlobContainer container =
blobClient.getContainerReference(containerName);
+ BlobServiceClient blobServiceClient =
AzureStorageUtils.createBlobServiceClient(context, null);
+ BlobContainerClient blobContainerClient =
blobServiceClient.getBlobContainerClient(containerName);
- final OperationContext operationContext = new OperationContext();
- AzureStorageUtils.setProxy(operationContext, context);
+ final ListBlobsOptions listBlobsOptions = new ListBlobsOptions()
+ .setPrefix(prefix)
+ .setDetails(new BlobListDetails()
+ .setRetrieveMetadata(true));
- for (ListBlobItem blob : container.listBlobs(prefix, true,
EnumSet.of(BlobListingDetails.METADATA), null, operationContext)) {
- if (blob instanceof CloudBlob) {
- CloudBlob cloudBlob = (CloudBlob) blob;
- BlobProperties properties = cloudBlob.getProperties();
- StorageUri uri =
cloudBlob.getSnapshotQualifiedStorageUri();
+ blobContainerClient.listBlobs().forEach(blob -> {
+ if (blob instanceof BlobItem) {
+ BlobItem blobItem = (BlobItem) blob;
+ BlobItemProperties properties = blobItem.getProperties();
+ BlobClient blobClient =
blobContainerClient.getBlobClient(blobItem.getName());
+ String uri = blobClient.getBlobUrl();
Builder builder = new BlobInfo.Builder()
-
.primaryUri(uri.getPrimaryUri().toString())
- .blobName(cloudBlob.getName())
- .containerName(containerName)
+ .primaryUri(uri)
+ .blobName(blobItem.getName())
+
.blobType(properties.getBlobType().toString())
+
.containerName(blobClient.getContainerName())
.contentType(properties.getContentType())
.contentLanguage(properties.getContentLanguage())
- .etag(properties.getEtag())
-
.lastModifiedTime(properties.getLastModified().getTime())
- .length(properties.getLength());
-
- if (uri.getSecondaryUri() != null) {
- builder.secondaryUri(uri.getSecondaryUri().toString());
- }
-
- if (blob instanceof CloudBlockBlob) {
- builder.blobType(AzureStorageUtils.BLOCK);
- } else {
- builder.blobType(AzureStorageUtils.PAGE);
- }
+ .etag(properties.getETag())
+
.lastModifiedTime(properties.getLastModified().toEpochSecond())
+
.length(properties.getContentLength());
+
Review comment:
Secondary URI is no longer receivable from v12 onwards. Would you
suggest we keep it in here as a backwards compatible output (but it will be
empty anyways...) or just remove it from BlobInfo class?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]