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

IncludeVersion flag on listObjects api with GCS does not return objects #1302

Closed samirp91 closed 2 months ago

samirp91 commented 2 months ago

Currently, I have a minio client instantiated with GCS as follows:

const MinioClient = new Minio.Client({
    endPoint: process.env.MINIO_ENDPOINT, // storage.googleapis.com
    useSSL: process.env.MINIO_USE_SSL === 'true',
    accessKey: process.env.MINIO_ACCESS_KEY,
    secretKey: process.env.MINIO_SECRET_KEY,
    port: parseInt(process.env.MINIO_PORT)
});

I am then calling the listObjects function with the IncludeVersion flag and I am receiving an empty response. If I call it without the flag, I get back the objects. I have enabled versioning in the GCS bucket as well.

const { bucketName, folder, includeVersions } = params;
    try {
        const objectsStream = MinioClient.listObjects(
            bucketName,
            folder,
            true,
            {
                IncludeVersion: !!includeVersions
            }
        );

        const object = [];
        objectsStream.on('data', (obj) => {
            console.log(obj);
        });
        for await (const obj of objectsStream) {
            object.push(obj);
        }

        return object;
    } catch (error) {
        throw error;
    }
}
prakashsvmx commented 2 months ago

We have functional tests that cover such scenarios. https://github.com/minio/minio-js/blob/d9644e516227c8be8181fa8ac9ada05792ee8661/tests/functional/functional-tests.js#L2254

So please check with the respective provider for compatibility. Could you please verify this AWS S3, and MinIO possibly with mc admin trace -v ALIAS ? Ot with MinioClient.traceOn()

klauspost commented 2 months ago

I don't think GCS supports versioning in their S3 API.

samirp91 commented 2 months ago

I don't think GCS supports versioning in their S3 API.

It's listed on their API page.

https://cloud.google.com/storage/docs/json_api/v1/objects/list

klauspost commented 2 months ago

@samirp91 That is not their S3 API.

klauspost commented 2 months ago

Either way, feel free to reach out to them.

samirp91 commented 2 months ago

@samirp91 That is not their S3 API.

Thanks for the response. Can you direct me to their S3 API? I've been searching for it and everything I've looked at so far (JSON API doc, XML API doc, @google-cloud/storage client API) has versions as an option. I'm sure I'm missing something but I can't figure out what.

TIA