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

ClientError (404) in S3Boto3Storage when calling write() #350

Closed
va-andrew opened this issue Jun 26, 2017 · 0 comments · Fixed by #1282
Closed

ClientError (404) in S3Boto3Storage when calling write() #350

va-andrew opened this issue Jun 26, 2017 · 0 comments · Fixed by #1282
Labels

Comments

@va-andrew
Copy link

When S3Boto3Storage has gzip enabled, the following code generates an error when writing to an S3 key that does not already exist:

with my_storage.open('new_key.txt', 'wb') as f:
    f.write(b'hello')

The stack trace indicates an error is happening for S3Boto3StorageFile._get_file():

            ...
            if self._storage.gzip and self.obj.content_encoding == 'gzip':
                self._file = GzipFile(mode=self._mode, fileobj=self._file, mtime=0.0)

Basically, by checking self.obj.content_encoding, Boto3 is performing a HeadObject() operation on the key, even though it doesn't exist yet, which is generating the 404.

Should the relevant code instead use the content-encoding guessed from the newly created file? That's what the S3Boto3Storage.save() method does and it doesn't have this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants