Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ValueError crash in S3Boto3Storage #437

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions storages/backends/s3boto3.py
Expand Up @@ -446,8 +446,7 @@ def _save(self, name, content):
# even if wrapped file-like object exists. To avoid Django-specific
# logic, pass internal file-like object if `content` is `File`
# class instance.
if isinstance(content, File):
content = content.file
content.name = name
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment does not match code anymore


self._save_content(obj, content, parameters=parameters)
# Note: In boto3, after a put, last_modified is automatically reloaded
Expand Down
6 changes: 4 additions & 2 deletions tests/test_s3boto3.py
Expand Up @@ -82,12 +82,13 @@ def test_storage_save(self):

obj = self.storage.bucket.Object.return_value
obj.upload_fileobj.assert_called_with(
content.file,
content,
ExtraArgs={
'ContentType': 'text/plain',
'ACL': self.storage.default_acl,
}
)
self.assertEqual(content.name, name)

def test_storage_save_gzipped(self):
"""
Expand All @@ -98,13 +99,14 @@ def test_storage_save_gzipped(self):
self.storage.save(name, content)
obj = self.storage.bucket.Object.return_value
obj.upload_fileobj.assert_called_with(
content.file,
content,
ExtraArgs={
'ContentType': 'application/octet-stream',
'ContentEncoding': 'gzip',
'ACL': self.storage.default_acl,
}
)
self.assertEqual(content.name, name)

def test_storage_save_gzip(self):
"""
Expand Down