[MIG] attachment_minio: odoo 13, additionally include mime-type per GITHUB#12

This commit is contained in:
Jared Kipe
2020-07-01 15:29:21 -07:00
parent 55b59d9642
commit 9e8e287e75
3 changed files with 12 additions and 2 deletions

View File

@@ -50,3 +50,11 @@ env.cr.commit()
If `attachment_minio` is not already installed, you can then install it and the migration If `attachment_minio` is not already installed, you can then install it and the migration
should be noted in the logs. **Ensure that the timeouts are long enough that the migration can finish.** should be noted in the logs. **Ensure that the timeouts are long enough that the migration can finish.**
### Base Setup
This module utilizes `base_attachment_object_storage`
The System Parameter `ir_attachment.storage.force.database` can be customized to
force storage of files in the database. See the documentation of the module
`base_attachment_object_storage`.

View File

@@ -1,6 +1,6 @@
{ {
"name": "Attachment MinIO", "name": "Attachment MinIO",
"version": "12.0.1.0.0", "version": "13.0.1.0.0",
"depends": [ "depends": [
"base_attachment_object_storage", "base_attachment_object_storage",
], ],

View File

@@ -85,7 +85,9 @@ 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)) with io.BytesIO(bin_data) as bin_data_io:
client.put_object(bucket, minio_key, bin_data_io, 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)