FL_GET_FILE_TYPE

Returns the file type (modality) of a FILE. This is a more general classification than the content type (see FL_GET_CONTENT_TYPE).

Syntax

Use one of the following:

FL_GET_FILE_TYPE( <scoped_url> )

FL_GET_FILE_TYPE( <metadata> )

Arguments

scoped_url

A valid scoped file URL.

metadata

An OBJECT containing all the required FILE metadata.

Returns

One of following values as a VARCHAR:

  • document

  • video

  • audio

  • image

  • compressed

  • unknown

Tip

To test if a file is of a particular type, use one of the FL_IS functions:

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_FILE_TYPE(f) FROM file_table;
Copy
+------------------------+
| FL_GET_FILE_TYPE(F)    |
|------------------------|
| image                  |
+------------------------+

Example using an input OBJECT:

CREATE TABLE file_table(f OBJECT);
INSERT INTO file_table SELECT OBJECT_CONSTRUCT('STAGE', 'MYSTAGE', 'RELATIVE_PATH', 'document.pdf', 'ETAG', '<ETAG value>',
  'LAST_MODIFIED', 'Wed, 11 Dec 2024 20:24:00 GMT', 'SIZE', 105859, 'FILE_TYPE', 'application/pdf');

SELECT FL_GET_FILE_TYPE(f) FROM file_table;
Copy
+------------------------+
| FL_GET_FILE_TYPE(F)    |
|------------------------|
| document               |
+------------------------+