我需要将一个大的Azure Blob复制到AWS S3,而不在内存中保留其副本。通过一些搜索,我已经找到了一堆例子并将它们结合在下面的脚本中。但这仍会将数据加载到内存中。有没有好的方法来避免这种情况?
import boto3
from azure.storage.blob import BlobClient
with io.BytesIO() as input_stream, io.BytesIO() as output_stream:
blob_client = BlobClient.from_connection_string(
conn_str=AZURE_CONNECTION_STRING,
container_name=container,
blob_name=filename,
)
blob_client.download_blob().readinto(input_stream)
input_stream.seek(0)
shutil.copyfileobj(input_stream, output_stream)
output_stream.seek(0)
boto3.resource("s3").Object(BUCKET_NAME, s3_key).put(Body=output_stream)