minio / minio-js

MinIO Client SDK for Javascript
https://docs.min.io/docs/javascript-client-quickstart-guide.html
Apache License 2.0
920 stars 271 forks source link

copyObject is still not supporting metadata #1286

Closed philkunz closed 3 months ago

philkunz commented 3 months ago

The copyObject method is still not supporting metadata. There is a old issue, that somehow got moved to python: https://github.com/minio/minio-py/issues/1192

prakashsvmx commented 3 months ago

Please share more details @philkunz ?. Is there a bug/error or missing implementation?

philkunz commented 3 months ago

yes, custom metadata is not supported, as shown in the linked issue. e.g. specifying x-amz-* key value pairs, is not supported in the copyObject method.

prakashsvmx commented 3 months ago

Please share code /trace

philkunz commented 3 months ago

There is like a super weird mixture of js and TypeScript files in src. What is the reason for that setup?

But here you go:

https://github.com/minio/minio-js/blob/e61a9e2a932f5e5c957f87ee406e6a5e3d970dae/src/minio.d.ts#L151-L163

There is no metadata to be specified.

compare the putObject method in comparison, where metadata can be specified:

https://github.com/minio/minio-js/blob/e61a9e2a932f5e5c957f87ee406e6a5e3d970dae/src/internal/client.ts#L1545-L1551

prakashsvmx commented 3 months ago

as you can see the typescript migration is in progress.. some APIs/methods are yet to be migrated . There is copyObjectV2 (yet same interface with different arguments) could you please double check if it is used and required parameters are passed in your application/client code ?.

prakashsvmx commented 3 months ago

Please take a look at https://github.com/minio/minio-js/pull/1151

GarryRocksman commented 2 months ago

as you can see the typescript migration is in progress.. some APIs/methods are yet to be migrated . There is copyObjectV2 (yet same interface with different arguments) could you please double check if it is used and required parameters are passed in your application/client code ?.

Hi @prakashsvmx

I’m currently facing an issue in my project where I am using version 8.0.0. I noticed that the copyObjectV2 method is not available in this version. However, I found that this method exists in the master branch. Could you please let me know when this method will be available in an official release?

prakashsvmx commented 2 months ago

@GarryRocksman

const result = await s3Client.copyObject(
    new CopySourceOptions({
      Bucket: bucketName,
      Object: objectName,
    }),
    new CopyDestinationOptions({
      Bucket: 'test-1-bucket',
      Object: objectName,
      MetadataDirective: 'REPLACE',
      UserMetadata: {
        'X-Amz-Height': '1300', //override this on the copy in target
      },
    }),
  )

This would work in both old and new version

GarryRocksman commented 2 months ago

@prakashsvmx i tried this but have got - Expected 4-5 arguments, but got 2.

prakashsvmx commented 2 months ago

Typescript migration is in progress. Until then you can please wait for release.

GarryRocksman commented 2 months ago

@philkunz
Maybe it will help someone who faces the same problem using TypeScript. If you add // @ts-ignore, this approach will work as @prakashsvmx said before

const result = await s3Client.copyObject(
    new CopySourceOptions({
      Bucket: bucketName,
      Object: objectName,
    }),
    new CopyDestinationOptions({
      Bucket: 'test-1-bucket',
      Object: objectName,
      MetadataDirective: 'REPLACE',
      UserMetadata: {
        'X-Amz-Height': '1300', //override this on the copy in target
      },
    }),
  )