☁️ Loving our new documentation website? Provide feedback in the CloudCannon Community! ✨

accepts_mime_types

Table of contents

Description:

This key defines which file types are available to select or upload to this input.

Accepted format is an array or comma-separated string of MIME types.

The special value "*" means any type is accepted.

Appears in:
└── _inputs
    └── *
        ├── File Input
        │   └── options
        │       └── accepts_mime_types
        └── URL Input
            └── options
                └── accepts_mime_types
Types:

This key represents a comma-separated string format for the accepts_mime_types key that restricts which file types are available to select or upload in File Inputs.

The value is a string containing MIME types separated by commas. Each MIME type specifies a file type that CloudCannon will allow for this input.

Available MIME types include image formats (image/x-icon, image/gif, image/jpeg, image/png, image/webp, image/bmp, image/svg+xml) and document formats (application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation).

Use the comma-separated format when you prefer a more compact configuration or when working with a small number of MIME types.

The special value "*" means any file type is accepted.

Show examplesHide examples

In this example, we have configured a File Input to accept only image files using a comma-separated string of image MIME types.

Copied to clipboard
_inputs:
  hero_image:
    type: file
    label: Hero Image
    options:
      accepts_mime_types: image/jpeg,image/png,image/webp
{
  "_inputs": {
    "hero_image": {
      "type": "file",
      "label": "Hero Image",
      "options": {
        "accepts_mime_types": "image/jpeg,image/png,image/webp"
      }
    }
  }
}

In this example, we have configured a File Input to accept only document files using a comma-separated string of document MIME types.

Copied to clipboard
_inputs:
  document:
    type: file
    label: Document
    options:
      accepts_mime_types: application/pdf,application/msword
{
  "_inputs": {
    "document": {
      "type": "file",
      "label": "Document",
      "options": {
        "accepts_mime_types": "application/pdf,application/msword"
      }
    }
  }
}

In this example, we have configured a File Input to accept any file type using the special "*" value.

Copied to clipboard
_inputs:
  any_file:
    type: file
    label: Any File
    options:
      accepts_mime_types: '*'
{
  "_inputs": {
    "any_file": {
      "type": "file",
      "label": "Any File",
      "options": {
        "accepts_mime_types": "*"
      }
    }
  }
}

This key represents an array format for the accepts_mime_types key that restricts which file types are available to select or upload in File Inputs.

The value is an array of MIME type strings. Each string specifies a file type that CloudCannon will allow for this input.

Available MIME types include image formats (image/x-icon, image/gif, image/jpeg, image/png, image/webp, image/bmp, image/svg+xml) and document formats (application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation).

Use the array format when you want to explicitly list multiple MIME types, making it easier to read and maintain in your configuration.

Show examplesHide examples

In this example, we have configured a File Input to accept only image files using an array of image MIME types.

Copied to clipboard
_inputs:
  hero_image:
    type: file
    label: Hero Image
    options:
      accepts_mime_types:
        - image/jpeg
        - image/png
        - image/webp
{
  "_inputs": {
    "hero_image": {
      "type": "file",
      "label": "Hero Image",
      "options": {
        "accepts_mime_types": [
          "image/jpeg",
          "image/png",
          "image/webp"
        ]
      }
    }
  }
}

In this example, we have configured a File Input to accept only document files using an array of document MIME types.

Copied to clipboard
_inputs:
  document:
    type: file
    label: Document
    options:
      accepts_mime_types:
        - application/pdf
        - application/msword
        - >-
          application/vnd.openxmlformats-officedocument.wordprocessingml.document
{
  "_inputs": {
    "document": {
      "type": "file",
      "label": "Document",
      "options": {
        "accepts_mime_types": [
          "application/pdf",
          "application/msword",
          "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
        ]
      }
    }
  }
}
Examples:

In this example, we have configured a Image Input to accept only JPEG or PNG files.

Copied to clipboard
_inputs:
  featured_image:
    type: image
    options:
      accepts_mime_types:
        - image/jpeg
        - image/png
{
  "_inputs": {
    "featured_image": {
      "type": "image",
      "options": {
        "accepts_mime_types": [
          "image/jpeg",
          "image/png"
        ]
      }
    }
  }
}
Open in a new tab