From 73e1b0eb9f4ea583d4e5fbef0aa8f65dae07a3f7 Mon Sep 17 00:00:00 2001 From: Marcel Fox Date: Fri, 22 Oct 2021 18:04:02 -0300 Subject: [PATCH] Returning content bytes on MinioBackend._save --- django_minio_backend/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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),