minio / minio-java

MinIO Client SDK for Java
https://docs.min.io/docs/java-client-quickstart-guide.html
Apache License 2.0
1.13k stars 485 forks source link

How do I modify the metadata of an object? #1561

Closed DaiYuanchuan closed 6 months ago

DaiYuanchuan commented 6 months ago

I want to modify the ContentType value of an object after the upload operation is completed.

I know that I can modify it when using CopyObject, but I only want to modify the ContentType value, not copy the entire object. If the object is very large, it would actually result in a copying operation, which would be very time-consuming.

balamurugana commented 6 months ago

Use the same object as source and destination object in copyObject()

DaiYuanchuan commented 6 months ago

Use the same object as source and destination object in copyObject()

It is also affected by the size of the file, with this object being 23.7GB(xx.2024.HDR.2160P.120FPS.mp4) and taking 6000ms, while the other object at 1.7GB took only 300ms.

Map<String, String> headers = Maps.newHashMapWithExpectedSize(5);
headers.put("Content-Type", "video/mp4");
ObjectWriteResponse future = minioClient.copyObject(
        CopyObjectArgs. builder()
                .bucket(BUCKET_NAME)
                .object("xx.2024.HDR.2160P.120FPS.mp4")
                .source(
                        CopySource. builder()
                                .bucket(BUCKET_NAME)
                                .object("xx.2024.HDR.2160P.120FPS.mp4")
                                .build())
                .metadataDirective(Directive.REPLACE)
                .userMetadata(headers)
                .build());
balamurugana commented 6 months ago

Raise an issue with the server you are using.