MIME_TYPE

Updated at:

Returns the MIME (Multipurpose Internet Mail Extensions) type of a file based on the file extension in a given URI.

Engine requirement

The MIME_TYPE function requires Ververica Runtime (VVR) 11.6.0 or later.

Syntax

VARCHAR MIME_TYPE(VARCHAR uri)

Parameters

Parameter

Type

Description

uri

VARCHAR

The URI of the file from which to detect the MIME type.

The following table lists the supported formats, common extensions, and corresponding MIME types.

Format

Common extensions

MIME type

BMP

.bmp

image/bmp

JPEG

.jpe, .jpeg, .jpg

image/jpeg

PNG

.png

image/png

TIFF

.tif, .tiff

image/tiff

WEBP

.webp

image/webp

HEIC

.heic

image/heic

PDF

.pdf

application/pdf

For file extensions not listed in the preceding table, the function returns "application/other".

Note
  • If uri is NULL, the function returns NULL.

Example 1

  • Test data

    Table 1. T1

    Input

    uri (VARCHAR)

    1

    http://example.com/example.jpeg

    2

    oss://example-bucket/example.pdf

    3

    NULL

  • Test statement

    SELECT 
        id,
        MIME_TYPE(uri) AS `value`
    FROM 
        T1;
  • Test result

    id (INT)

    value (VARCHAR)

    1

    image/jpeg

    2

    application/pdf

    3

    NULL

References