4

When we retrieve a static resource and convert into dx format, cli will rename the .resource to .png if mime type in the .resource-meta.xml is image/png.

Is there a list of such mime types that cli deals with and renames it for us?

1 Answer 1

2

I have not seen any documented list of supported mime to extension mapping. Looking at the source for the sfdx CLI, specifically the staticResourceMatadataTransformer.js I can say that:

  1. It uses a "mime" library that supports registered mappings from mime type to file extension.
  2. It includes some special mappings that are built-in, including JavaScript, ZIP, HAML, XML and PNG.

The "mime" database itself that SFDX uses has the following in its README:

This is a database of all mime types.
It consists of a single, public JSON file and does not include any logic,
allowing it to remain as un-opinionated as possible with an API.
It aggregates data from the following sources:

- http://www.iana.org/assignments/media-types/media-types.xhtml
- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
- http://hg.nginx.org/nginx/raw-file/default/conf/mime.types

## Installation

bash
npm install mime-db

### Database Download

If you're crazy enough to use this in the browser, you can just grab the
JSON file using [jsDelivr](https://www.jsdelivr.com/). It is recommended to
replace `master` with [a release tag](https://github.com/jshttp/mime-db/tags)
as the JSON format may change in the future.

https://cdn.jsdelivr.net/gh/jshttp/mime-db@master/db.json

## Usage

js
var db = require('mime-db')

// grab data on .js files
var data = db['application/javascript']

## Data Structure

The JSON file is a map lookup for lowercased mime types.
Each mime type has the following properties:

- `.source` - where the mime type is defined.
    If not set, it's probably a custom media type.
    - `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types)
    - `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml)
    - `nginx` - [nginx media types](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types)
- `.extensions[]` - known extensions associated with this mime type.
- `.compressible` - whether a file of this type can be gzipped.
- `.charset` - the default charset associated with this type, if any.

If unknown, every property could be `undefined`.

Thus it looks like the list of supported mime types is:

  1. Very long and
  2. Inherited from several different external sources
2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .