AWS Lambda Python environment
I tried to guess_type`` .webp
in the Python environment of AWS Lambda.
python
import mimetypes
print(mimetypes.guess_type('.webp'))
# none
It has become none.
python
import mimetypes
print(mimetypes.types_map['.webp'])
# none
webp doesn't exist in types_map, so add it
python
import mimetypes
mimetypes.add_type('image/webp', '.webp')
print(mimetypes.guess_type('.webp'))
# image/webp
Settled.
The mimetypes dictionary is environment-dependent, so if you can't guess_type
or guess_extention
, check if the target exists in the dictionary.
If it does not exist, it can be added with ʻadd_type`.
Reference) https://note.nkmk.me/python-mimetypes-usage/
Recommended Posts