Sanity v3: File type options.accept causes "split is not a function" error
You're running into the accept.split is not a function error because the options.accept property needs to be a string, not an array. According to the Sanity file type documentation, the accept option should be formatted as a string that matches the HTML accept attribute specification.
Here's the fix for your schema:
{
name: "document",
type: "file",
title: "Document",
options: {
accept: "application/pdf", // String instead of array
},
}If you need to accept multiple file types, use a comma-separated string:
{
name: "document",
type: "file",
title: "Document",
options: {
accept: "application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",
},
}Why this format? The accept option is passed directly to the underlying HTML <input type="file"> element's accept attribute, which expects a comma-separated string of valid file type specifiers according to web standards. The documentation recommends using MIME types (like "application/pdf") over file extensions (like ".pdf") for better drag-and-drop hover notifications.
This same format applies to the image type as well - if you have image fields with options.accept, they should also use comma-separated strings rather than arrays.
Show original thread4 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.