question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

content_md5 causes TypeError: string argument without an encoding

See original GitHub issue
  • Package Name: azure.storage.blob
  • Package Version: 12.3.2
  • Operating System: MacOS and Ubuntu Linux
  • Python Version: 3.7

Describe the bug When uploading a large file I’m trying to use the content_md5 property of the ContentSettings object.

When I try to set the set_http_headers with the documented type str this fails with TypeError: string argument without an encoding. this comes from the construction of the standard bytearray. This is all a bit goofy because I already had to use the base64 package which returns bytes.

To Reproduce Steps to reproduce the behavior:

simplified for the issue. My code will chunk to generate md5.

with open(filepath, 'rb') as f:
  hash = hashlib.md5(f.read())
  f.seek(0)
  blobclient.upload_blob(f, content_settings=ContentSettings(content_md5=b64encode(hash.digest()).decode('utf-8)))

Providing this content settings configuration for upload_blob and set_http_headers methods both cause this exception. Looks like different code paths causing the same problem, copy and paste-like. Seems to work fine with V2 of the SDK.

Expected behavior No exceptions and correct md5 so a consumer can validate the result of the whole file.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
msftbot[bot]commented, Aug 10, 2020

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

0reactions
xiafu-msftcommented, Dec 1, 2020

we will close this for now and make the doc clear

Read more comments on GitHub >

github_iconTop Results From Across the Web

az storage file upload fails with content-md5 parameter #23179
... line 399, in create_file TypeError: string argument without an encoding. To Reproduce. Generate a MD5 hash of a file using:.
Read more >
Amazon MWS SubmitFeed Content-MD5 HTTP header did not ...
I am no expert in MWS, but it is quite evident that you are base-64 encoding the string value of the md5 hash...
Read more >
Request / Response Objects — Werkzeug Documentation (2.2 ...
Your WSGI application is always passed two arguments. ... will be encoded as UTF-8. Passing an iterable of bytes or strings makes this...
Read more >
s3 - Amazon Web Services - Go SDK - AWS Documentation
Requests Amazon S3 to encode the object keys in the response and specifies ... type Error struct { // The error code is...
Read more >
S3 — Boto3 Docs 1.26.30 documentation - Amazon AWS
Parameters : operation_name (string) -- The operation name. ... Setting this header to true causes Amazon S3 to use an S3 Bucket Key...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found