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:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.
we will close this for now and make the doc clear