none
[Python][Azure Storage] Blob Storage: Upload zip file with python error -> UnicodeDecodeError: ascii RRS feed

  • Question

  • Hi all,

    I not able to perform the following operations on a zip file with python:

    - create_blob_from_path
    - create_blob_from_Bytes

    I always get the following error:  UnicodeDecodeError: ascii

    This is what I’m trying:

    #1 get blob from azure storage

    azure_blob = block_blob_service.get_blob_to_path(container_name=BLOB_CONTAINER_NAME, blob_name=BLOBNAME, file_path="test.zip", open_mode='wb')

    #add some files and upload zip back

    ....

    block_blob_service = BlockBlobService(account_name=STORAGE_ACCOUNT, account_key=STORAGE_KEY)

    f = open('test.zip', "rb")
        block_blob_service.create_blob_from_bytes(container_name=BLOB_CONTAINER_NAME, blob_name='test.zip', blob=f.read())

    block_blob_service.create_blob_from_path(container_name=BLOB_CONTAINER_NAME, blob_name="test.zip", file_path="test.zip")    

    I'm able to upload a new zip which I create manually but I'm not able to upload the zip file which is downloaded from azure blob storage.

    Any help is much appreciated,

    Anton






    Friday, June 10, 2016 12:32 PM

Answers

  • Hi,

    Thank you for posting here!

    Are you following this document to download and upload blobs to azure blob storage?

    Please run below command

    pip install azure --upgrade

    It will upgrade a few components, then run your command. And check it’s make any difference.

    Regards,

    Vikranth S. 

    Sunday, June 12, 2016 10:10 AM

All replies

  • Hello,

    Thank you for posting here.

    We are checking on the query and would get back to you soon on this.

    I apologize for the inconvenience and appreciate your time and patience in this matter.

    Regards,

    Pradeep

    Saturday, June 11, 2016 11:31 AM
  • Hi,

    Thank you for posting here!

    Are you following this document to download and upload blobs to azure blob storage?

    Please run below command

    pip install azure --upgrade

    It will upgrade a few components, then run your command. And check it’s make any difference.

    Regards,

    Vikranth S. 

    Sunday, June 12, 2016 10:10 AM
  • Here is the similar issue at GitHub https://github.com/kennethreitz/requests/issues/2933 and SO http://stackoverflow.com/questions/34468386/unicodedecodeerror-when-uploading-image-bytes-to-azure-block-blob-via-python-sdk.

    Could you please try to upgrade azure sdk for python first? Please try

    pip install azure --upgrade

    Any further concern, please feel free to let me know.

    Tuesday, June 21, 2016 2:18 AM
    Moderator