# MimeTypeBasedParser

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/document_loaders/parsers/generic/MimeTypeBasedParser)

Parser that uses `mime`-types to parse a blob.

This parser is useful for simple pipelines where the mime-type is sufficient
to determine how to parse a blob.

To use, configure handlers based on mime-types and pass them to the initializer.

Example:

    .. code-block:: python

        from langchain_community.document_loaders.parsers.generic import MimeTypeBasedParser

        parser = MimeTypeBasedParser(
            handlers={
                "application/pdf": ...,
            },
            fallback_parser=...,
        )

## Signature

```python
MimeTypeBasedParser(
    self,
    handlers: Mapping[str, BaseBlobParser],
    *,
    fallback_parser: Optional[BaseBlobParser] = None,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `handlers` | `Mapping[str, BaseBlobParser]` | Yes | A mapping from mime-types to functions that take a blob, parse it       and return a document. |
| `fallback_parser` | `Optional[BaseBlobParser]` | No | A fallback_parser parser to use if the mime-type is not              found in the handlers. If provided, this parser will be              used to parse blobs with all mime-types not found in              the handlers.              If not provided, a ValueError will be raised if the              mime-type is not found in the handlers. (default: `None`) |

## Extends

- `BaseBlobParser`

## Constructors

```python
__init__(
    self,
    handlers: Mapping[str, BaseBlobParser],
    *,
    fallback_parser: Optional[BaseBlobParser] = None,
) -> None
```

| Name | Type |
|------|------|
| `handlers` | `Mapping[str, BaseBlobParser]` |
| `fallback_parser` | `Optional[BaseBlobParser]` |


## Properties

- `handlers`
- `fallback_parser`

## Methods

- [`lazy_parse()`](https://reference.langchain.com/python/langchain-community/document_loaders/parsers/generic/MimeTypeBasedParser/lazy_parse)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/a6a6079511ac8a5c1293337f88096b8641562e77/libs/community/langchain_community/document_loaders/parsers/generic.py#L14)