🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

File type in Sanity.io currently does not support using an existing document, but it will be available in the next release.

11 replies
Last updated: Aug 26, 2021
I feel like this is an easy solution but I just can’t find it. Just a simple file type but it currently only allows to upload a document and not use an existing one. In the block type I needed two separate annotation items to do this but in a simple file type can it set to allow uploading a new document or use an existing one?
Aug 20, 2021, 7:36 PM
Hi Peter. You didn’t miss anything! Asset source support for the File field is not currently available. However, the good news is that it was just merged into next , which means it should be part of the next release. In the meantime, files are available using the media plugin.
Aug 20, 2021, 9:17 PM
So glad it’s coming to a future release! Any rough timeline?
Aug 20, 2021, 9:25 PM
I actually don’t know, but there is this release forthcoming.
Aug 20, 2021, 9:31 PM
user U
Check out v2.16.0. 👍
Aug 24, 2021, 2:31 PM
user U
Check out v2.16.0. 👍
Aug 24, 2021, 2:31 PM
YES! 🏃‍♂️
Aug 24, 2021, 2:34 PM
It sure does work. The only thing is that a user has to select “Uploaded Images” even though it could be any other file type, in our case it’s mostly PDF’s so it’s odd for the user to select images in order to get to PDF’s. But this is a small thing in the grand scheme of things. This is awesome!
Aug 24, 2021, 5:34 PM
It sure does work. The only thing is that a user has to select “Uploaded Images” even though it could be any other file type, in our case it’s mostly PDF’s so it’s odd for the user to select images in order to get to PDF’s. But this is a small thing in the grand scheme of things. This is awesome!
Aug 24, 2021, 5:34 PM
I’m glad to hear that, Peter.
For the dropdown, could you give this a try in your schema file that’s using the
file
type?

import Default from 'part:@sanity/form-builder/input/file/asset-source-default'

export default {
  // ...
  {
    name: 'fieldName',
    title: 'Field Name',
    type: 'file',
    options: {
      sources: [Default],
    },
    // ...
  },
  // ...
}
Aug 24, 2021, 6:37 PM
Hi Peter. I’m told that the “Uploaded Images” regression for file types is resolved in 2.17.0, so you shouldn’t need to use my workaround if you upgrade to that version. 👍
Aug 26, 2021, 1:43 PM
What great timing! Today i was going to implement the workaround. Thank You. The Sanity team is a great team. 🙂
Aug 26, 2021, 1:54 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?