Skip to content

Commit dd999ae

Browse files
committed
Add content-type support
1 parent 14db6bd commit dd999ae

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

minio_backend/fields.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import base64
55
from io import BytesIO
66
from .minio_backend import get_minio_client
7+
import magic
78

89

910
class S3File(fields.text):
@@ -55,8 +56,12 @@ def set(self, cursor, obj, rid, name, value, user=None, context=None):
5556

5657
content = base64.b64decode(value)
5758
length = len(content)
59+
content_type = magic.from_buffer(content, mime=True)
5860
content = BytesIO(content)
59-
client.put_object(self.bucket, filename, content, length=length)
61+
client.put_object(
62+
self.bucket, filename, content, length=length,
63+
content_type=content_type
64+
)
6065
value = filename
6166
return super(S3File, self).set(
6267
cursor, obj, rid, name, value, user, context

minio_backend/requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
minio<7.0.0
1+
minio<7.0.0
2+
python-magic

0 commit comments

Comments
 (0)