我有 Azure 容器,其中保存了一些文件。 我需要使用 python 代码访问它们 我在 JAVA 中做了同样的事情,但我无法在 Python 中复制它
//这是相同的java代码。
CloudBlobContainer Con = new CloudBlobContainer("Some SAS URI");
CloudBlockBlob blob1 = Con.getBlockBlobReference(fileName);
blob1.downloadToFile(filePath+fileName+userName);
最佳答案
python中没有等效的方法,可以看一下Container class of python
您应该始终将 BlockBlobService
与 sas token (如果您有 sas uri,您可以从中获取 sas token )或帐户 key 一起使用,如果您使用 sas token ,如下所示:
from azure.storage.blob import BlockBlobService
blobservice = BlockBlobService("storage_account",sas_token="?sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2019-04-24T10:01:58Z&st=2019-04-23T02:01:58Z&spr=https&sig=xxxxxxxxx")
blobservice.get_blob_to_path("container_name","blob_name","local_file_path")
关于python - 在 PYTHON 中使用 SAS URI 从 AZURE BLOB CONTAINER 下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55794030/