How to allow both upload and reference existing documents in Sanity file field?
The file type in Sanity Studio v3 doesn't automatically provide both upload and browse/select functionality by default in the way you might expect. Let me clarify what's actually happening:
What the file field provides by default
When you define a basic file field, the Studio will show an upload interface that allows you to:
- Upload new files (drag-and-drop or click to browse your local files)
- Access files through configured asset sources
About asset sources
The key to accessing existing files is the options.sources property. This controls which asset sources are available to the file field. Asset sources can include:
- Your Sanity asset library (the default source)
- External services like Cloudinary, Unsplash, etc.
- Custom asset sources you've built
{
name: 'myFile',
type: 'file',
title: 'My File',
options: {
sources: [] // Configure which sources are available
}
}Why annotations need two separate items
In Portable Text annotations, you're working within inline text marks, which have different constraints than standalone fields. That's why you needed separate annotation definitions - one for uploading/linking new files and one for referencing existing file documents.
Accessing existing files
To browse and select from previously uploaded files in your Sanity asset library, you'll want to ensure your file field has access to the default Sanity asset source. The documentation mentions custom asset sources as a way to control and extend this functionality.
If you're not seeing the ability to browse existing files, check:
- That you have files already uploaded to your project
- Your
options.sourcesconfiguration (if you've set it) - That you're using a recent version of Sanity Studio v3
The file type works similarly to the image type in terms of asset management, but the documentation doesn't explicitly state that a "browse existing" button appears by default - it focuses more on the upload functionality and the ability to configure asset sources.
Show original thread11 replies
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.