-
Notifications
You must be signed in to change notification settings - Fork 58
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
PUT object with Content-Length header. #73
PUT object with Content-Length header. #73
Conversation
This is required by some Swift object storage implementation, like Ceph RADOS Gateway
👍 for tests. Looks perfectly fine to me, but I don't know too much about what |
Looking at the source of swiftclient it can be other things as well:
|
https://docs.djangoproject.com/en/1.9/_modules/django/core/files/storage/ It seems like the Django @Blacktorn What matters is probably more what the the Django Maybe we should use |
@@ -262,13 +262,15 @@ def _save(self, name, content, headers=None): | |||
content.seek(0) | |||
else: | |||
content_type = mimetypes.guess_type(name)[0] | |||
content_length = os.fstat(content.fileno()).st_size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming we always get a Django File
object or one if their subclasses we should probably use File.size
to get the byte size of the object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the Django docs, that would work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick test:
>>> from django.core.files.base import ContentFile
>>> f1 = ContentFile("esta sentencia está en español")
>>> import os
>>> os.fstat(f1.fileno())
Traceback (most recent call last):
File "<console>", line 1, in <module>
io.UnsupportedOperation: fileno
>>> f1.size
30
2 similar comments
Pull request updated assuming we always get a Django |
Perfect. I think we probably should expand Looks ready for merge 👍 |
Thanks @valerytschopp ! |
This is required by some Swift object storage implementation, like Ceph RADOS Gateway