Working with Files
Files in Val
Val supports generic file uploads for any file type, including videos, PDFs, audio files, and more. Files work similarly to images, but with more flexibility in file types.
Key Differences from Images
The main differences when working with files instead of images:
Use
s.file()instead ofs.image()in your schemaUse
c.file()instead ofc.image()for local filesYou can specify accepted file types with the
acceptoption (e.g.,accept: 'video/*',accept: '.pdf,.doc')When you use
accept: 'video/*', Val Studio will render it as a video with preview
Schema and Content
Using Files in Components
When using files in your components, access the URL using the .url property:
Basic usage
Using val.attrs and val.raw
For advanced use cases where you need to control visual editing attributes, you can use val.attrs() and val.raw() with the file URL:
More Information
For detailed information about adding metadata, working with remote files, and using the CLI or VS Code extension, see the Images Guide. The workflow is identical - just use s.file() and c.file() instead of s.image() and c.image().
For a comprehensive guide on working specifically with videos, see the Videos Guide.