Use download_file instead of download_fileobj to solve the 0 size issue

This commit is contained in:
Wei Xu 2024-11-07 17:48:45 +11:00
parent 014d4873c8
commit 7535bac9e4
No known key found for this signature in database

View File

@ -57,7 +57,7 @@ class S3StorageProvider(StorageProvider):
try:
bucket_name, key = file_path.split("//")[1].split("/", 1)
with NamedTemporaryFile() as f:
self.client.download_fileobj(bucket_name, key, f)
self.client.download_file(bucket_name, key, f.name)
yield f.name
except Exception as e:
raise RuntimeError(f"Error downloading file {file_path} from S3: {e}")