我在用适用于 Python 的 Microsoft Azure SDK https://github.com/Azure/azure-sdk-for-python在项目中。我想将 Blob 从一个容器移动或复制到另一个容器。例如
https://demostorage.blob.core.windows.net/image-container/pretty.jpg
我想把这个斑点移到
https://demostorage.blob.core.windows.net/demo-container/
我在 python SDK 中找到了以下方法,但无法理解它。
def copy_blob(self, container_name, blob_name,...):
我怎样才能做到这一点?谢谢
我就是这样做的。
from azure.storage.blob import BlobService
def copy_azure_files(self):
blob_service = BlobService(account_name='account_name', account_key='account_key')
blob_name = 'pretty.jpg'
copy_from_container = 'image-container'
copy_to_container = 'demo-container'
blob_url = blob_service.make_blob_url(copy_from_container, blob_name)
# blob_url:https://demostorage.blob.core.windows.net/image-container/pretty.jpg
blob_service.copy_blob(copy_to_container, blob_name, blob_url)
#for move the file use this line
blob_service.delete_blob(copy_from_container, blob_name)
我还没有找到任何 Blob Move 方法。所以我使用了复制方法,然后执行Blob函数。
这是我的解决方案。如果您有更好的方法来处理这一切,请与我分享。
注意:我没有使用任何自定义方法,所有这些方法都包含在 SDK 中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)