[英]How to download a list of files from Azure Blob Storage given SAS URI and container name using Python?
[英]Download file from AZURE BLOB CONTAINER using SAS URI in PYTHON
我有Azure容器,用於存放一些文件。 我需要使用python代碼訪問它們,我在JAVA中做了同樣的事情,但是我無法在Python中復制它
//這是相同的java代碼。
CloudBlobContainer Con = new CloudBlobContainer("Some SAS URI");
CloudBlockBlob blob1 = Con.getBlockBlobReference(fileName);
blob1.downloadToFile(filePath+fileName+userName);
python中沒有等效的方法,您可以看一下python的Container類
您應該始終將BlockBlobService
與sas令牌(如果您有sas uri,可以從中獲取sas令牌)或帳戶密鑰一起使用,例如如果您使用sas令牌,則如下所示:
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")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.