Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create payloadFromHashAssumes that the request body is either string or byte - throws exceptions for type _io.BufferedReader #14

Open
ashishkumar468 opened this issue Aug 25, 2023 · 0 comments

Comments

@ashishkumar468
Copy link

ashishkumar468 commented Aug 25, 2023

Came across this library when using mlflow.log_artifacts with AWS_SIGV4 request signing enabled. When trying to upload the artifact with a put call, this library throws an exception saying that _io.BufferedReader cannot be encoded. Possible solution (or a better version of it).
At line https://github.com/andrewjroth/requests-auth-aws-sigv4/blob/master/requests_auth_aws_sigv4/__init__.py#L141C14-L141C14

  if r.body:
                if isinstance(r.body, bytes):
                    log.debug("Request Body: <bytes> %s", r.body)
                    payload_hash = hashlib.sha256(r.body).hexdigest()
                elif isinstance(r.body, bytes):
                    log.debug("Request Body: <str> %s", r.body)
                    payload_hash = hashlib.sha256(r.body.encode('utf-8')).hexdigest()
                else
                     log.debug("Request Body Object's instance type: {type(obj)} ")
                     body_buffer=r.body
                     file_content=body_buffer.read()
                     body_buffer.seek(0)
                     payload_hash = payload_hash = hashlib.sha256(file_content).hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant