title: How to best use Python 3's mimetypes module in AWS Lambda?
body: <p>I deployed a working Flask application to AWS Lambda via Zappa. One of the things working locally but not on Lambda is the call to</p>
  
  <pre><code>mimetypes.guess_extension
  </code></pre>
  
  <p>In particular, locally, on my Mac, the guessed extension for</p>
  
  <pre><code>application/vnd.openxmlformats-officedocument.wordprocessingml.document
  </code></pre>
  
  <p>is properly</p>
  
  <pre><code>.docx
  </code></pre>
  
  <p>but on Lambda, it's</p>
  
  <pre><code>None
  </code></pre>
  
  <p>The way <code>mimetypes</code> works is that it consults the host machine's <code>mime.types</code> file, and this file either does not exist on Lambda or something does but it does not have many types.</p>
  
  <p>So how can get this module to work on Lambda? The <a href="https://docs.python.org/3/library/mimetypes.html" rel="nofollow noreferrer">documentation</a> mentions an <code>init</code> function in the module which accepts files, but that doesn't seem right for a Lambda. I could, I guess bundle up the entire 48K mime.types file on my Mac into my deployed Lambda (as a file?), but that seems like overkill, and was wondering if perhaps I missed something and that Lambdas <em>should</em> have access to this information without uploading files?</p>
  
  <p>I checked PyPI and found the packages <code>mime</code> and <code>common-mimetypes</code> but they have not been touched in years.</p>
  
  <p>Any best practices I am overlooking here?</p>