# MimeTypeHelper

`MimeTypeHelper` class provides methods for getting a file extension (starts with dot, e.g. ".pdf") by a MIME type and vice versa.

## GetMimeType()

Returns MIME type by file extension.

```csharp
string extension = ".pdf";
string mimeType = MimeTypeHelper.GetMimeType(extension); // Returns "application/pdf".
```

All parameters:

| Param name | Param type | Description         |
| ---------- | ---------- | ------------------- |
| extension  | `string`   | The file extension. |

## GetExtension()

Returns file extension by MIME type.

```csharp
string mimeType = "application/pdf";
string extension = MimeTypeHelper.GetExtension(mimeType); // Returns ".pdf".
```

All parameters:

| Param name      | Param type | Description                                                                                          |
| --------------- | ---------- | ---------------------------------------------------------------------------------------------------- |
| mimeType        | `string`   | The MIME type.                                                                                       |
| throwIfNotFound | `bool`     | The flag indicates the need for an exception if the MIME type is not found. Default value is `true`. |

## GetExtensions()

Returns file extensions by MIME type. Some MIME types has any various of extensions. For example:

```csharp
string mimeType = "image/jpeg";
IEnumerable<string> extensions = MimeTypeHelper.GetExtensions(mimeType); // Returns (".jpe", ".jpg", ".jpeg")
```

All parameters:

| Param name      | Param type | Description                                                                                          |
| --------------- | ---------- | ---------------------------------------------------------------------------------------------------- |
| mimeType        | `string`   | The MIME type.                                                                                       |
| throwIfNotFound | `bool`     | The flag indicates the need for an exception if the MIME type is not found. Default value is `true`. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.structr.dev/utilities/io/mimetypehelper.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
