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

Print out MD5, but get a byte array. #13104

Closed
likun47 opened this issue Aug 13, 2020 · 6 comments
Closed

Print out MD5, but get a byte array. #13104

likun47 opened this issue Aug 13, 2020 · 6 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)

Comments

@likun47
Copy link

likun47 commented Aug 13, 2020

-azure_storage_blob-12.3.2:

  • Azure SDK for Python:
  • Windows 10:
  • Python 3.0:

Describe the bug
I have a customer, she wrote some code wanted to get a MD5 content, it was supposed to return a string, but she got a byte array.

To Reproduce
Steps to reproduce the behavior:

  1. Running the code below:
    from azure.storage.blob import BlobServiceClient
    blob_service_client = BlobServiceClient.from_connection_string(connect_str);
    container_client = blob_service_client.get_container_client(container_name)
    blob_list = container_client.list_blobs(name_starts_with=src);
    for blob in blob_list:
    print( blob.name + "\t" + str(blob.content_settings.content_md5) )

Output:
quickstart.txt bytearray(b'\x93\x8f1xZ\xc2]\xc1\xcb\x1f\xd5\x10\xef .\x92')

Expected behavior
Return result should be a string: 'k48xeFrCXcHLH9UQ7yAukg==

Screenshots
N/A

Additional context
Background information from my customer:

from azure.storage.blob import BlockBlobService
block_blob_service = BlockBlobService(account_name=acct_name, account_key=acct_key)
blob_list = block_blob_service.list_blobs(container_name, src, include='metadata')
for blob in blob_list:
print blob.name + "\t" + blob.properties.content_settings.content_md5
The code above works well. But we upgraded our system to python 3 and some featuresare gone, for example, 'blob_tier' is not an attribute of Blobproperties under BlockBlobService.

That is the reason we changed to BlobServiceClient. Then I encountered ‘md5’ issue.

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Aug 13, 2020
@kaerm kaerm added Client This issue points to a problem in the data-plane of the library. Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files) labels Aug 13, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 13, 2020
@ghost
Copy link

ghost commented Aug 13, 2020

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

@likun47
Copy link
Author

likun47 commented Aug 13, 2020

More specific configuration:
pip3 freeze
azure-core==1.8.0
azure-storage-blob==12.4.0
certifi==2020.6.20
cffi==1.14.1
chardet==3.0.4
cryptography==3.0
idna==2.10
isodate==0.6.0
msrest==0.6.18
oauthlib==3.1.0
pycparser==2.20
requests==2.24.0
requests-oauthlib==1.3.0
scour==0.36
six==1.11.0
urllib3==1.25.10

@xiafu-msft
Copy link
Contributor

Hi @likun47

Thanks for reaching out! We will discuss this and get back to you!

@xiafu-msft
Copy link
Contributor

Hi @likun47

We know it's weird, sorry about that... While we had a discussion and currently we don't plan to make it to a str since it's a breaking change to other customers.
So currently you can do base64 encode the bytes and utf-8 decode it like this:
encode_base64(content_md5).decode('utf-8')

Sorry again about the inconvenience. Let me know if you have any concern....

@likun47
Copy link
Author

likun47 commented Aug 21, 2020 via email

@tasherif-msft
Copy link
Contributor

Hi @likun47 we will proceed to close this issue since it looks like it is resolved on your end, if anything else comes up feel free to reach out :)

openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-python that referenced this issue Feb 23, 2021
add cosmosdb python track2 pipeline (Azure#13104)

* add cosmosdb python track2 pipeline

* fix duplication error
00Kai0 added a commit that referenced this issue Mar 2, 2021
* CodeGen from PR 13104 in Azure/azure-rest-api-specs
add cosmosdb python track2 pipeline (#13104)

* add cosmosdb python track2 pipeline

* fix duplication error

* test,version,CHANGELOG

* fix test

* regen sdk

* fix changelog

* fix readme

* fix

Co-authored-by: SDKAuto <sdkautomation@microsoft.com>
Co-authored-by: Yan Zhang (WICRESOFT NORTH AMERICA LTD) <v-yanzhang@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

No branches or pull requests

4 participants