Class FileContentTypes
1. Extension → CONTENT_TYPE. TO_FILE derives a staged file's
CONTENT_TYPE from its FILE NAME EXTENSION ALONE — never from its bytes. The decisive live
pair: a file holding real PNG bytes named png_named.txt reports text/plain, while a
file holding plain text named text_named.png reports image/png. Anything whose
extension is not in the table below — including a name with no extension at all — is
application/octet-stream (measured for noext, .bz2, .avro,
.orc, .parquet, .woff2 and .yaml).
2. CONTENT_TYPE → category. FL_GET_FILE_TYPE and the five
FL_IS_* predicates classify on the descriptor's CONTENT_TYPE — not on the path, not
on the bytes. Proven live by feeding TRY_TO_FILE a hand-built descriptor whose
RELATIVE_PATH and CONTENT_TYPE disagree: ('x.txt', 'image/png') classifies
image and ('x.png', 'text/plain') classifies document.
The category tables are CLOSED EXACT-MATCH SETS — emphatically not a image/* style prefix
rule, and not case- or whitespace-insensitive. Every one of these was measured:
image/x-bogus, video/x-bogus, audio/x-bogus, text/x-bogus and
application/x-bogus are all unknown; so are IMAGE/PNG (wrong case),
" image/png" / "image/png " (untrimmed) and
application/gzip;charset=utf-8 (parameters not stripped). Within a family, membership is
arbitrary and must not be guessed: audio/mpeg is audio but audio/mp4 is
unknown; text/plain is a document but text/tab-separated-values is
unknown; application/gzip is compressed but application/x-gzip is
unknown; application/zip is compressed but application/x-7z-compressed is
unknown.
The sets also OVERLAP. video/x-msvideo (an .avi file) is in BOTH the video and the
audio set — live, FL_IS_VIDEO and FL_IS_AUDIO are both TRUE for it while
FL_GET_FILE_TYPE answers video. So FL_IS_x(f) is NOT
FL_GET_FILE_TYPE(f) = 'x': each predicate is its own membership test, and
FL_GET_FILE_TYPE resolves the tie by checking image, then video, then audio, then document,
then compressed.
A content type absent from every set — and a NULL content type — is unknown, with all five
predicates FALSE.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionThe measured extension table, for the test that pins it.static StringFL_GET_FILE_TYPE: the single category name for a content type —image,video,audio,document,compressedorunknown.static StringTheCONTENT_TYPESnowflake reports for a staged file with this relative path — from the extension only,application/octet-streamwhen the extension is unknown or absent.static booleanFL_IS_AUDIO's membership test — includesvideo/x-msvideo, see the class note.static booleanisCompressed(String contentType) FL_IS_COMPRESSED's membership test — noteapplication/x-gzipis NOT in it.static booleanisDocument(String contentType) FL_IS_DOCUMENT's membership test — exact match against the measured document set.static booleanFL_IS_IMAGE's membership test — exact match against the measured image set.static booleanFL_IS_VIDEO's membership test — exact match against the measured video set.
-
Field Details
-
UNKNOWN
FL_GET_FILE_TYPEfor anything in no category, and for a NULL file or content type.- See Also:
-
-
Method Details
-
forPath
TheCONTENT_TYPESnowflake reports for a staged file with this relative path — from the extension only,application/octet-streamwhen the extension is unknown or absent.- Parameters:
relativePath- the file's path within its stage- Returns:
- the content type, never null
-
fileType
FL_GET_FILE_TYPE: the single category name for a content type —image,video,audio,document,compressedorunknown. Checked in that order, which is what makes an.avi(in both the video and audio sets) avideo.- Parameters:
contentType- the descriptor'sCONTENT_TYPE, may be null- Returns:
- the category name, never null
-
isImage
FL_IS_IMAGE's membership test — exact match against the measured image set. -
isVideo
FL_IS_VIDEO's membership test — exact match against the measured video set. -
isAudio
FL_IS_AUDIO's membership test — includesvideo/x-msvideo, see the class note. -
isDocument
FL_IS_DOCUMENT's membership test — exact match against the measured document set. -
isCompressed
FL_IS_COMPRESSED's membership test — noteapplication/x-gzipis NOT in it. -
extensionTable
The measured extension table, for the test that pins it.
-