File Directory Schema
s.filedir(dir, options)
A directory of files that is the whole module - the same idea as s.imagedir(), for any file type rather than images. Where s.file() defines a single field, s.filedir() defines a module that holds many files at once, keyed by their file path.
The content is a record: each key is the path of a file in the collection's directory, and each value is the mimeType Val read off that file. Entries appear when a file is uploaded through Val Studio, the CLI or the VS Code extension - you do not write them by hand.
Fields elsewhere pick from a collection with s.file(collectionModule), the same way s.image(galleryModule) picks from an image gallery.
Like image galleries, file collections are listed under Media in Val Studio rather than in the Explorer file tree.
For fonts, use s.fontdir(): an s.filedir() that accepts only font types. Val Studio previews any file whose mimeType is a font, in either.
Upgrading? s.filedir() replaces s.fileset({ dir, ...options }), which still works but is deprecated. Move dir out of the options and into the first argument; nothing else changes.
/docs/files, /docs/api/schema/file, /docs/api/schema/fontdir, /docs/api/schema/imagedir, /docs/remoteOptions:
Required. Where the files in this collection are stored. Must start with /public. Two collections may not claim the same directory. The options below go in an object after it.
Required. Which file types the collection accepts. A comma-separated list of one or more MIME types, or unique file type specifiers.
Methods:
Store the files of this collection on Val's remote server instead of in your git repository. See the remote files guide.