diff --git a/django_minio_backend/models.py b/django_minio_backend/models.py index 6ba99b8..ece28ec 100644 --- a/django_minio_backend/models.py +++ b/django_minio_backend/models.py @@ -144,11 +144,14 @@ def _save(self, file_path_name: str, content: InMemoryUploadedFile) -> str: # Upload object file_path: Path = Path(file_path_name) # app name + file.suffix + content_bytes: io.BytesIO = io.BytesIO(content.read()) + content_length: int = len(content_bytes.getvalue()) + self.client.put_object( bucket_name=self.bucket, object_name=file_path.as_posix(), - data=content, - length=content.size, + data=content_bytes, + length=content_length, content_type=self._guess_content_type(file_path_name, content), metadata=self._META_KWARGS.get('metadata', None), sse=self._META_KWARGS.get('sse', None),