MinioClient doesn't return userMetaData

29 Views Asked by At

My goal is to list all the objects in a bucket that contain some keys and values. So in short I need an API where I assign a Map<String,String> to an object upload it to S3 and can find it later using this Map.

For this I use MinioClient https://min.io/docs/minio/linux/developers/java/API.html

I thought that I could upload an object and add userMetadata to it:

    var builder = PutObjectArgs.builder()
            .bucket(bucket)
            .object(objectName)
            .userMetadata(userMetadata)
            .stream(inputStream, -1, DEFAULT_PART_SIZE);

    minioClient.putObject(builder.build());

and then list all the objects with the specified prefix using the flag .includeUserMetadata(true):

   Iterable<io.minio.Result<io.minio.messages.Item>> minioClient.listObjects(ListObjectsArgs.builder()
                                        .bucket(bucket)
                                        .recursive(true)
                                        .prefix(pathPrefix)
                                        .includeUserMetadata(true)
                                        .build())

and then check whether item.userMetadata contains all the entries from the map used as a filter.

However all the items have userMetadata = null. Why?

Currently I workaround the problem by calling minioClient.statObject() on each item: var statObjectMetadata =

var userMetadata = minioClient.statObject(StatObjectArgs.builder()
                                            .bucket(bucket)
                                            .object(item.objectName())
                                            .build()).userMetadata();

It would be great if someone knows another solution to this problem.

Using

<minio.version>8.5.2</minio.version>

P.S. I updated the version to 8.5.3 and includeUserMetadata(true) began working, but I noticed that it doesn't contain the same key in userMetadata I used before uploading the object to the storage. For example I used the key my_file_type but item contained X-Amz-Meta-My_file_type.

0

There are 0 best solutions below