mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-13 04:46:52 +08:00
fix azure stream download (#6063)
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from contextlib import closing
|
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
from azure.storage.blob import AccountSasPermissions, BlobServiceClient, ResourceTypes, generate_account_sas
|
from azure.storage.blob import AccountSasPermissions, BlobServiceClient, ResourceTypes, generate_account_sas
|
||||||
@@ -38,10 +37,9 @@ class AzureStorage(BaseStorage):
|
|||||||
|
|
||||||
def generate(filename: str = filename) -> Generator:
|
def generate(filename: str = filename) -> Generator:
|
||||||
blob = client.get_blob_client(container=self.bucket_name, blob=filename)
|
blob = client.get_blob_client(container=self.bucket_name, blob=filename)
|
||||||
with closing(blob.download_blob()) as blob_stream:
|
blob_data = blob.download_blob()
|
||||||
while chunk := blob_stream.readall():
|
for chunk in blob_data.chunks():
|
||||||
yield chunk
|
yield from chunk
|
||||||
|
|
||||||
return generate()
|
return generate()
|
||||||
|
|
||||||
def download(self, filename, target_filepath):
|
def download(self, filename, target_filepath):
|
||||||
|
|||||||
Reference in New Issue
Block a user