Issue uploading images to Sanity Studio

50 replies
Last updated: Mar 18, 2024
Hello! I have an issue uploading images to the Sanity Studio. Can anyone help?
AI Update

I'd be happy to help troubleshoot your image upload issue! There are several common causes for image upload problems in Sanity Studio. Let me walk you through the most likely solutions:

1. Check your schema configuration

First, make sure your image field is properly configured in your schema:

{
  name: 'mainImage',
  title: 'Main Image',
  type: 'image',
  options: {
    hotspot: true // optional, enables cropping/focal point
  }
}

2. Verify CORS origins

This is the most common culprit! Your Studio's domain needs to be added to your project's CORS origins:

  • Go to manage.sanity.io
  • Select your project
  • Navigate to Settings → API settings
  • Add your Studio URL to CORS origins (e.g., http://localhost:3333 for local development or your production Studio URL)

3. Check authentication

Make sure you're logged in to the Studio. If your session has expired, uploads will fail. Try logging out and back in.

4. File size and format

  • Check if your image file is too large (default max is 5MB for free plans)
  • Ensure the file format is supported (JPG, PNG, GIF, SVG, WebP are standard)

5. Browser console errors

Open your browser's developer console (F12) and look for any error messages when you attempt to upload. Common errors include:

  • 401/403 errors → authentication/CORS issue
  • Network errors → connectivity problem
  • 413 errors → file too large

6. Network/firewall issues

If you're behind a corporate firewall or VPN, it might be blocking uploads to Sanity's asset CDN. Try disconnecting from VPN or checking with your IT department.

What specific behavior are you seeing? For example:

  • Does nothing happen when you click upload?
  • Do you see an error message?
  • Does the upload start but then fail?

The error details will help narrow down the exact cause. In the meantime, checking CORS settings is usually the quickest fix for most upload issues!

Show original thread
50 replies
Can you provide some details of the issue you're facing?
Are you uploading images through the javascript client (or any other client)?

Do you have an error message of the fact?
This is the error im getting:
And for referance this is my schema:
Is this upload is being made on a frontend app like nextjs?
Are you adding the extension of the image? such as:
filename:
myImage.png
Im uploading through localhost. I run Sanity Dev
And what do you mean if im adding the extension?
This how my Ui looks:
Also, some images work and some dont when uploading. Maybe its related to the file size. The one that doesnt work is 9mb
ooooooh, through sanity studio ok ok
let me try uploading something bigger to see if I face the same error
you should try that too
try some other image
Ok so I uploaded an image that was actually 13mb as a jpg and 5mb as a png and both work.. So it doesnt seem to be the size or format thats the issue
try this in the image that throws error:

https://www.metadata2go.com/
Ok I did. And what should I be looking for?
I compare the meta data of the image that worked and the one that didnt. And the one that didnt doesnt have anything special, but it does have extra fields that the other doesnt
then I have no idea
Ok I did. And what should I be looking for?
if the metadata is broken somehow, this site would alarm you
Can you share the image that’s giving you trouble? Are you on the latest version of the Studio?
This is the image
And im on 3.27.0. ill upgrade to 3.34.0 to see if it helps
I'll try to upload this image to see if helps
I just tried on 3.33 and it worked!
Worked on 3.28
You’ll likely need to delete the image via the CLI or Media Plugin then reupload. Trying to upload after it already exists in your dataset won’t work, unfortunately.
And how would I do that. Delete vie CLI?
Also newset version didnt fix for me
Using the CLI:
sanity dataset delete <dataset> <assetID>
To install/use the cli:

npm install -g @sanity/cli

sanity login

sanity dataset delete <dataset> <assetID>
Ok did the install of the CLi. And how would I know which dataset and assetID to delete?
the problem is the asset id
but
the dataset you can get on your account, though sanity's website
there is a JS script that you can run to DELETE all assets not associated to a document on sanity
let me see if I can find
my man
user M
is the best
So I went to the script. Paste it, added the token, ran in. It deleted 15 assets. And still error!
I do appreciate the help a lot tho!
Try to download the image from slack... and upload it.
The error seems related to the image and nothing else.
I mean at this point. Probably the best solution
Yeah...
Don't get stuck because of an image.
Yep that worked. But it wasnt only that image. it was all images in that folder. So at this point ill just try uploading to google drive, downloading and uploading to sanity..
Thank you for the support again!
it might be a permission issue
good to know
happy codding

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.

Was this answer helpful?