LanguageValues and typesStandard typesWeb and network
FileType
On this page
A file's media type: image/png, application/pdf and so on.
Use it to say which kinds of file an upload accepts.
Shape
One of these 8 values:
| Value | Written |
|---|---|
FileType.png |
image/png |
FileType.jpeg |
image/jpeg |
FileType.webp |
image/webp |
FileType.pdf |
application/pdf |
FileType.csv |
text/csv |
FileType.tsv |
text/tab-separated-values |
FileType.json |
application/json |
FileType.json_lines |
application/jsonl |
Example
FileType.pngtext.parse(raw, as: FileType) reads one from text that comes from outside. Text that isn't one at all fails malformed, such as png or image/tiff.
Good to know
- It holds a fixed list. Any other media type, such as
image/tiff, is refused. ==tells you whether two are the same.<andlist.sort_bydon't take it.
In JSON
A string, in a request, a response or json.write:
"image/png""application/pdf"
Details
Text form, storage, how it is shown, and operations
FileType is in the group Web and network, and has been in Jadpo since 0.1.0.
Text form
text.from writes one standard text form, the same form text.parse reads back: image/png and application/pdf.
How it is stored
It is stored in one column named for the field, of type text. application/pdf is stored as 'application/pdf'.
How it is shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
image/png |
image/png |
application/pdf |
application/pdf |
Operations
It also takes text.parse, text.from, text.format, json.read, json.write and ==. How every standard type behaves says how they work.
Markdown for agents: /docs/types/type-file-type.md.Built from Jadpo main at aee2e8f.