lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello, everyone!

I have just finished the first version of `mimetypes`, a Lua library that guesses MIME types for filenames. For example:

    > mimetypes = require 'mimetypes'
    > = mimetypes.guess "index.html"
    text/html
    > = mimetypes.guess "mimetypes.lua"
    text/x-lua
    > = mimetypes.guess "report.docx"
    application/vnd.openxmlformats-officedocument.wordprocessingml.document
    > = mimetypes.guess "README"
    text/plain
    > = mimetypes.guess "notreal.extension"
    nil

You can also have it guess from your own database of MIME types. The built-in database was mostly obtained from Python 2.7.1's `mimetypes.py` module, as well as Xavante's MIME types file and Rack::Mime from Rack.

Its home page is at <https://bitbucket.org/leafstorm/lua-mimetypes/>, and you can download it from the "Downloads" tab there. (If I got a MIME type wrong, file an issue on the site so as not to flood the list.) All the documentation is in the README file, and there is also a small test file you can run.

The rockspec hasn't been published yet, but it should be soon, and once it is you will be able to run `luarocks install mimetypes` to install it.
--
Thanks, Matthew Frazier