I needed to add image upload to a custom role, so that an author role could add a profile picture

4 replies
Last updated: Sep 30, 2020

Hope this helps someone else. I needed to add image upload to a custom role, so that an author role could add a profile picture. It needed:

 {
          filter: '_id in path("**")',
          permissions: ['read', 'create', 'update'],
 },

Sep 29, 2020, 3:01 AM

Thanks for sharing back Jesse! 🙌
Quick note: the above gives the permissions to any

_id
matching that path, so also non-image documents. This could be just fine depending on what you have in mind for the custom role. However, if you’d like to target images more specifically, you could also try a filter like this:
{
  filter: '_type == "sanity.imageAsset"',
  permissions: ['read', 'create', 'update'],
},

Sep 29, 2020, 5:34 AM

ah!! sanity. prefix !!!

Sep 30, 2020, 2:14 AM

thanks

user M

Sep 30, 2020, 2:14 AM

i was so close

Sep 30, 2020, 2:15 AM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.