Managing files in Sanity Studio and GraphQL API

4 replies
Last updated: May 17, 2020
Hey guys, I know sanity has a file type, how do I actually manage files through Sanity Studio and the GraphQL API? I want to make some documents available for download and fetch them for download from the frontend but I'm not sure how to work with the file type 🤔
I added a type to schema with type file but I'm not sure how to interact with it
May 17, 2020, 6:09 PM
Do I need to implement it in a document to interact with it?
May 17, 2020, 6:11 PM
on the document you want to add the file(s) to:
{
      title: "Files",
      name: "files",
      type: "array",
      of: [{ type: "file" }],
},
or just type: 'file' if you dont want an array
May 17, 2020, 6:30 PM
user K
ended up converting my schema from
type: 'file', fields: [...]
to `type: 'document', fields: [...]`and now it's working
May 17, 2020, 6:39 PM
awesome!
May 17, 2020, 6:40 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?