Skip to content

Commit

Permalink
Add comment for why we need to seek the download to the start
Browse files Browse the repository at this point in the history
  • Loading branch information
said-moj committed Aug 16, 2023
1 parent 662d385 commit 0f311be
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cla_backend/libs/aws/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def download_file(cls, bucket_name, key):
obj = cls.get_s3_connection(bucket_name).bucket.Object(cls.clean_name(key))
data = NamedTemporaryFile()
obj.download_fileobj(data)
# This required otherwise any file reads will start at the end which
# leads to an empty file being downloaded (zero bytes)
data.seek(0)
return {"headers": {"Content-Type": obj.content_type}, "body": data}
except ClientError:
Expand Down

0 comments on commit 0f311be

Please sign in to comment.