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)
This commit is contained in:
David Dufresne
2020-05-25 16:38:48 -04:00
committed by Jared Kipe
parent f1a5ff4052
commit e60c827861

View File

@@ -85,7 +85,10 @@ class MinioAttachment(models.Model):
client = self._get_minio_client() client = self._get_minio_client()
bucket = self._get_minio_bucket(client) bucket = self._get_minio_bucket(client)
minio_key = self._get_minio_key(key) 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 self._get_minio_fname(bucket, minio_key)
return super(MinioAttachment, self)._store_file_write(key, bin_data) return super(MinioAttachment, self)._store_file_write(key, bin_data)