duncanlock.net

Better content-type guessing in AWS CLI

The content-type guessing done by AWS CLI is based on the mimetype definitions available on your system. You can improve the mimetype guessing by updating these definitions.

It uses the python mimetypes lib to do this and checks the following files:

knownfiles = [
    "/etc/mime.types",
    "/etc/httpd/mime.types",                    # Mac OS X
    "/etc/httpd/conf/mime.types",               # Apache
    "/etc/apache/mime.types",                   # Apache 1
    "/etc/apache2/mime.types",                  # Apache 2
    "/usr/local/etc/httpd/conf/mime.types",
    "/usr/local/lib/netscape/mime.types",
    "/usr/local/etc/httpd/conf/mime.types",     # Apache 1.2
    "/usr/local/etc/mime.types",                # Apache 1.3
    ]

I would suggest leaving /etc/mime.types (and any of the other files in this list that already exist on your system) alone. I would create one of the files that you don’t have – something like this:

$ sudo mkdir -p /etc/apache2
$ curl -s "http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=co" | sudo tee /etc/apache2/mime.types

This downloads the latest mimetypes definitions from the Apache project and saves it as /etc/apache2/mime.types. I don’t have the Apache web server installed on this system, so it wasn’t there before.


Related Posts


Comments