File field type
The file field type allows you to store one or more files in your records. Files are stored with automatically generated unique names and can be protected or publicly accessible.Key features
- Single or multiple file uploads per field
- MIME type validation
- File size limits (default: 5MB per file)
- Automatic thumbnail generation for images
- Protected file access with token authentication
- Support for local and S3 storage backends
How files are stored
When you upload a file to a record, PocketBase:- Validates the file against the field’s constraints (size, MIME type)
- Generates a unique filename with a random suffix
- Stores the file in the record’s directory:
{collection}/{recordId}/{filename} - Saves only the filename in the database record field
- Generates thumbnails if the file is an image and thumbs are configured
File names are automatically normalized and sanitized. PocketBase appends a random 10-character suffix to prevent filename collisions and enhance security.
File field configuration
You can configure file fields with the following options:Example configuration
File URL structure
Files are served through the API endpoint:Query parameters
thumb- Request a specific thumbnail size (e.g.,?thumb=100x100)token- File access token (required for protected files)download- Force download instead of inline display (e.g.,?download=1)
Example URLs
Thumbnail sizes
For image files, you can configure automatic thumbnail generation using these formats:WxH(e.g.,100x300) - Crop to WxH from centerWxHt(e.g.,100x300t) - Crop to WxH from topWxHb(e.g.,100x300b) - Crop to WxH from bottomWxHf(e.g.,100x300f) - Fit inside WxH without cropping0xH(e.g.,0x300) - Resize to height, preserve aspect ratioWx0(e.g.,100x0) - Resize to width, preserve aspect ratio
Thumbnails are generated on-demand on first request and cached for subsequent requests. The default thumbnail size is
100x100.Protected files
WhenProtected is set to true, users need to provide a file token to access the file:
Storage backends
PocketBase supports two storage backends:- Local filesystem - Default, stores files in
pb_data/storage/ - S3-compatible storage - AWS S3, MinIO, DigitalOcean Spaces, etc.
Next steps
File upload
Learn how to upload files to records
File download
Understand the file download workflow
S3 storage
Configure S3-compatible storage