瀏覽代碼

fix azure stream download (#6063)

tags/0.6.13
Jyong 1 年之前
父節點
當前提交
cbbe28f40d
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 3 行新增5 行删除
  1. 3
    5
      api/extensions/storage/azure_storage.py

+ 3
- 5
api/extensions/storage/azure_storage.py 查看文件

@@ -1,5 +1,4 @@
from collections.abc import Generator
from contextlib import closing
from datetime import datetime, timedelta, timezone

from azure.storage.blob import AccountSasPermissions, BlobServiceClient, ResourceTypes, generate_account_sas
@@ -38,10 +37,9 @@ class AzureStorage(BaseStorage):

def generate(filename: str = filename) -> Generator:
blob = client.get_blob_client(container=self.bucket_name, blob=filename)
with closing(blob.download_blob()) as blob_stream:
while chunk := blob_stream.readall():
yield chunk

blob_data = blob.download_blob()
for chunk in blob_data.chunks():
yield from chunk
return generate()

def download(self, filename, target_filepath):

Loading…
取消
儲存