From e60c8278618aa763cdbff2a7925b5e4a22bce7ac Mon Sep 17 00:00:00 2001 From: David Dufresne <27902736+ddufresne@users.noreply.github.com> Date: Mon, 25 May 2020 16:38:48 -0400 Subject: [PATCH] Add the content type to files stored in minio Before this commit, an error is raised in google-chrome when opening Odoo. The mime type octet-stream is not a valid stylesheet mimetype. (cherry picked from commit 5e924ff417565a1988746f209046b9bee27c6952) --- attachment_minio/models/ir_attachment.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/attachment_minio/models/ir_attachment.py b/attachment_minio/models/ir_attachment.py index 7a50ad16..38b08db1 100644 --- a/attachment_minio/models/ir_attachment.py +++ b/attachment_minio/models/ir_attachment.py @@ -85,7 +85,10 @@ class MinioAttachment(models.Model): client = self._get_minio_client() bucket = self._get_minio_bucket(client) minio_key = self._get_minio_key(key) - client.put_object(bucket, minio_key, io.BytesIO(bin_data), len(bin_data)) + client.put_object( + bucket, minio_key, io.BytesIO(bin_data), len(bin_data), + content_type=self.mimetype, + ) return self._get_minio_fname(bucket, minio_key) return super(MinioAttachment, self)._store_file_write(key, bin_data)