Tôi đang sử dụng kho Django với phần phụ trợ s3boto. Theo sự cố này, http://code.larlet.fr/django-storages/issue/5/s3botostorage-set-content-type-header-acl-fixed-use-http-and-disable-query-auth-by Tôi có một loạt tệp (tất cả chúng) có loại nội dung 'application/octet-stream'. Cho rằng tôi có một thể hiện của <class 'boto.s3.key.Key'>
, làm cách nào tôi có thể đặt content_type?Sử dụng boto, đặt content_type trên các tệp đã có trên s3
In [29]: a.file.file.key.content_type
Out[29]: 'application/octet-stream'
In [30]: mimetypes.guess_type(a.file.file.key.name)[0]
Out[30]: 'image/jpeg'
In [31]: type(a.file.file.key)
Out[31]: <class 'boto.s3.key.Key'>