FL_GET_CONTENT_TYPE

Returns the content type (also known as the MIME type) of a FILE.

Syntax

Use one of the following:

FL_GET_CONTENT_TYPE( <scoped_url> )

FL_GET_CONTENT_TYPE( <metadata> )

Arguments

scoped_url

A valid scoped file URL.

metadata

An OBJECT containing all the required FILE metadata.

Returns

Aa VARCHAR value with the MIME type of the file, for example 'image/png' for a PNG image file.

Examples

Example using an input FILE:

CREATE TABLE file_table(f FILE);
INSERT INTO file_table
    SELECT TO_FILE(BUILD_STAGE_FILE_URL('@mystage', 'image.png'));

SELECT FL_GET_CONTENT_TYPE(f) FROM file_table;
Copy
+------------------------+
| FL_GET_CONTENT_TYPE(F) |
|------------------------|
| image/png              |
+------------------------+

Example using an input OBJECT:

CREATE TABLE file_table(f OBJECT);
INSERT INTO file_table
  SELECT object_construct('STAGE', 'MYSTAGE', 'RELATIVE_PATH', 'image.jpg', 'ETAG', '<ETAG value>',
      'LAST_MODIFIED', 'Wed, 11 Dec 2024 20:24:00 GMT', 'SIZE', 105859, 'CONTENT_TYPE', 'image/jpg');

SELECT FL_GET_CONTENT_TYPE(f) FROM file_table;
Copy
+------------------------+
| FL_GET_CONTENT_TYPE(F) |
|------------------------|
| image/jpg              |
+------------------------+