drkameleon / mimetypes.art

MIME content type registry & recognition

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mimetypes

MIME content type registry & recognition package for Arturo



What does this package do?

This package provides an ample (2000+) entry database of MIME content typse and their corresponding extensions and allows to easily look up the suitable extensions by file extension (or file path). It also supports the reverse operation: look up possible mime types, based on a given extension.

Tip

For the data, the package has been based on the very useful list compiled by the mime-db project.

How do I use it?

Simply import it and use the included mimetype function:

import "mimetypes"!

mimetype "jpg"              ; => ["image/jpeg"]
mimetype "somefile.jpg"     ; => ["image/jpeg"]
mimetype "boom"             ; => []

mimetype.extensions "image/jpeg"
; => ["jpe","jpeg","jpg"]

Important

In case no suitable MIME type has been found for a given extension/path, or if the given MIME type isn't associated with any known extensions, then mimetype will return an empty block!

Function reference

mimetype

Description

get mimetype(s) from given extension/filepath

Usage
mimetype location :string
Attributes
Option Type(s) Description
extensions get possible file extensions for given mimetype instead
Returns
  • :block

License

MIT License

Copyright (c) 2024 Yanis Zafirópulos

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

MIME content type registry & recognition

License:MIT License