4

根据手册,我应该使用这段代码:

from azure.storage.blob import ContentSettings
block_blob_service.create_block_blob_from_path(
    'mycontainer',
    'myblockblob',
    'sunset.png',
    content_settings=ContentSettings(content_type='image/png')
            )

但是得到了这个错误:

AttributeError: 'BlockBlobService' object has no attribute 'create_block_blob_from_path'

尝试从git,以及从pip

pip install azure-storage
4

1 回答 1

4

与最新的 Python SDK 相比,我认为该教程已过时。我认为create_block_blob_from_path不再存在 - 我查看了 sdk 代码(此处)。块 blob 和页 blob 有单独的导入,方法是create_blob_from_path.

因此,通过简单的更正:

from azure.storage.blob import BlockBlobService
from azure.storage.file import ContentSettings
blob_service = BlockBlobService(account_name="<storagename>",account_key="<storagekey>")

content_settings = ContentSettings(content_type = "image/png")
blob_service.create_blob_from_path("mycontainer","myblockblob","sunset.png",content_settings)
于 2016-02-26T14:32:29.383 回答