Skip to content

Commit

Permalink
Merge pull request #28 from MarcelFox/develop
Browse files Browse the repository at this point in the history
Returning content bytes on MinioBackend._save
  • Loading branch information
theriverman authored Oct 26, 2021
2 parents 744c4e0 + 73e1b0e commit 3e34707
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions django_minio_backend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,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),
Expand Down

0 comments on commit 3e34707

Please sign in to comment.