Skip to content

add support for Azure Blob index tags #563

@alapierre

Description

@alapierre

Feature description

currently it is only possible to use Metadata on UploadRequest and cannot add tags. In Azure Blob Storage index tags can by used to search blobs, so in many cases Micronaut implementation is useless if one need add tags for search functionality.

With Azure SDK it can be made like:

val blob = blobClient.getBlobClient(path);
            BlobHttpHeaders headers = new BlobHttpHeaders().setContentType("........................");

            BlobParallelUploadOptions options = new BlobParallelUploadOptions(BinaryData.fromStream(source))
                    .setHeaders(headers)
                    .setTags(Map.of("issued", DateTimeFormatter.ofPattern("yyyy-MM-dd").format(attributes.issueDate())));

val r = blob.uploadWithResponse(options, null, null);

I tryed this:

UploadRequest request = UploadRequest
            .fromPath(Path.of("..................pdf")
                    , "blob/path");

        val res = objectStorage.upload(request, options -> {
            options.setTags(Map.of("type", "FS", "issued", "2024-12-01"));
        });

but it not works, probably because of this (tags are not copied):

    private BlockBlobSimpleUploadOptions toBlockBlobSimpleUploadOptions(@NonNull BlobParallelUploadOptions options, @NonNull InputStream inputStream, @NonNull long length) {
        BlockBlobSimpleUploadOptions simpleUploadOptions = new BlockBlobSimpleUploadOptions(new BufferedInputStream(inputStream), length);
        simpleUploadOptions.setMetadata(options.getMetadata());
        simpleUploadOptions.setHeaders(options.getHeaders());
        return simpleUploadOptions;
    }

from AzureBlobStorageOperations

BTW using client.deleteIfExists() is in my opinion bad practice:

  1. by default uploadWithResponse overrides existing blob, according to javadoc: "Creates a new blob, or updates the content of an existing blob"
  2. how it will works with version-level immutability support containers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: improvementA minor improvement to an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions