Git Product home page Git Product logo

Comments (13)

trollfot avatar trollfot commented on June 25, 2024 1

Thank you. I just raised the concern there. I suspect it's minio's responsability and the header is just not present there.

from miniopy-async.

trollfot avatar trollfot commented on June 25, 2024 1
        stat = await storage.stat_object(
            userid, child.object_name, request_headers={
                "x-amz-checksum-mode": "ENABLED"
            })

<CIMultiDictProxy('Accept-Ranges': 'bytes', 'Content-Length': '66113', 'Content-Type': 'image/jpeg', 'Etag': '"aa183ad8c63be503136cf2cb6f364c9a"', 'Last-Modified': 'Fri, 17 Nov 2023 11:53:38 GMT', 'Server': 'MinIO', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'Vary': 'Origin', 'Vary': 'Accept-Encoding', 'X-Amz-Checksum-Sha256': 'MGCj+pPNMgMINi1y/RL1qZtCIyZCBWyFPLwtDtlWtdU=', 'X-Amz-Id-2': 'dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8', 'X-Amz-Request-Id': '179866FF4F9AC0FE', 'X-Content-Type-Options': 'nosniff', 'X-Xss-Protection': '1; mode=block', 'x-amz-meta-filename': 'unnamed.jpg', 'Date': 'Fri, 17 Nov 2023 11:55:06 GMT')>

The checksum is there, as expected. I had a look at the code, it's now symmetrical with the other get methods. I think it's very nice and a special thank you to you for the reactivity and help.

from miniopy-async.

hlf20010508 avatar hlf20010508 commented on June 25, 2024

I've tried this in official minio-py, and the result is the same, no such x-amz-checksum-X header.
I think you should open an issue there.

from miniopy-async.

trollfot avatar trollfot commented on June 25, 2024

It seems the query functions do not allow for extra headers to be added and a special header is needed to get the checksum back. Currently, The only headers passed along are the server side encryption (ssec).

from miniopy-async.

trollfot avatar trollfot commented on June 25, 2024

minio/minio-py#1330

from miniopy-async.

trollfot avatar trollfot commented on June 25, 2024

get_object and fget_object have the ability to get an extra dict of request headers. Maybe this could be done for stat_object.

from miniopy-async.

hlf20010508 avatar hlf20010508 commented on June 25, 2024

I still can't get it even in get_object.
What's your parameters in put_object and get_object? I guess I missed something.

from miniopy-async.

trollfot avatar trollfot commented on June 25, 2024

It seems that, to get back a checksum header, you have to set a request header "x-amz-checksum-mode: ENABLED". (https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html#API_HeadObject_RequestSyntax). You need to have set a "x-amz-checksum-X" header on the put_object (x-amz-checksum-sha256 for example).

from miniopy-async.

hlf20010508 avatar hlf20010508 commented on June 25, 2024

You mean like this?

import hashlib
import base64
import io

buffer = io.BytesIO('test')

sha256 = hashlib.sha256(buffer.getvalue()).digest()
b64_sha256 = base64.b64encode(sha256).decode()

client.put_object(
    "my-bucket",
    "my-object",
    buffer,
    len(buffer.getvalue()),
    metadata={
        'x-amz-checksum-mode': 'ENABLED',
        'x-amz-checksum-sha256': b64_sha256
    },
)

from miniopy-async.

trollfot avatar trollfot commented on June 25, 2024

As i understand it from the docs, 'x-amz-checksum-mode': 'ENABLED', is only required on get/head methods, to signal the server that you want the checksum back as a metadata with the rest of the info

from miniopy-async.

hlf20010508 avatar hlf20010508 commented on June 25, 2024

ok, i got it.

from miniopy-async.

hlf20010508 avatar hlf20010508 commented on June 25, 2024

Done.
Please update using pip install git+https://github.com/hlf20010508/miniopy-async.git to have a test.
If nothing wrong, I'll publish new version

from miniopy-async.

hlf20010508 avatar hlf20010508 commented on June 25, 2024

You're welcome.
New version published.

from miniopy-async.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.