Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Issue with uploading images to Sanity Studio, seeking help and troubleshooting steps.

50 replies
Last updated: Mar 18, 2024
Hello! I have an issue uploading images to the Sanity Studio. Can anyone help?
Mar 18, 2024, 3:35 PM
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?
Mar 18, 2024, 4:59 PM
This is the error im getting:
Mar 18, 2024, 5:25 PM
And for referance this is my schema:
Mar 18, 2024, 5:26 PM
Is this upload is being made on a frontend app like nextjs?
Mar 18, 2024, 5:34 PM
Are you adding the extension of the image? such as:
filename:
myImage.png
Mar 18, 2024, 5:35 PM
Im uploading through localhost. I run Sanity Dev
Mar 18, 2024, 5:38 PM
And what do you mean if im adding the extension?
Mar 18, 2024, 5:39 PM
This how my Ui looks:
Mar 18, 2024, 5:39 PM
Also, some images work and some dont when uploading. Maybe its related to the file size. The one that doesnt work is 9mb
Mar 18, 2024, 5:40 PM
ooooooh, through sanity studio ok ok
Mar 18, 2024, 5:44 PM
let me try uploading something bigger to see if I face the same error
Mar 18, 2024, 5:44 PM
you should try that too
Mar 18, 2024, 5:44 PM
try some other image
Mar 18, 2024, 5:44 PM
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
Mar 18, 2024, 5:47 PM
try this in the image that throws error:

https://www.metadata2go.com/
Mar 18, 2024, 5:47 PM
Ok I did. And what should I be looking for?
Mar 18, 2024, 5:49 PM
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
Mar 18, 2024, 5:51 PM
then I have no idea
Mar 18, 2024, 5:57 PM
Ok I did. And what should I be looking for?
if the metadata is broken somehow, this site would alarm you
Mar 18, 2024, 5:57 PM
Can you share the image that’s giving you trouble? Are you on the latest version of the Studio?
Mar 18, 2024, 5:59 PM
This is the image
Mar 18, 2024, 6:00 PM
And im on 3.27.0. ill upgrade to 3.34.0 to see if it helps
Mar 18, 2024, 6:01 PM
I'll try to upload this image to see if helps
Mar 18, 2024, 6:04 PM
I just tried on 3.33 and it worked!
Mar 18, 2024, 6:05 PM
Worked on 3.28
Mar 18, 2024, 6:08 PM
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.
Mar 18, 2024, 6:10 PM
And how would I do that. Delete vie CLI?
Mar 18, 2024, 6:17 PM
Also newset version didnt fix for me
Mar 18, 2024, 6:17 PM
Using the CLI:
sanity dataset delete <dataset> <assetID>
Mar 18, 2024, 6:18 PM
To install/use the cli:

npm install -g @sanity/cli

sanity login

sanity dataset delete <dataset> <assetID>
Mar 18, 2024, 6:18 PM
Ok did the install of the CLi. And how would I know which dataset and assetID to delete?
Mar 18, 2024, 6:20 PM
the problem is the asset id
Mar 18, 2024, 6:21 PM
but
Mar 18, 2024, 6:21 PM
the dataset you can get on your account, though sanity's website
Mar 18, 2024, 6:21 PM
there is a JS script that you can run to DELETE all assets not associated to a document on sanity
Mar 18, 2024, 6:21 PM
let me see if I can find
Mar 18, 2024, 6:21 PM
my man
user M
is the best
Mar 18, 2024, 6:22 PM
So I went to the script. Paste it, added the token, ran in. It deleted 15 assets. And still error!
Mar 18, 2024, 6:32 PM
I do appreciate the help a lot tho!
Mar 18, 2024, 6:32 PM
Try to download the image from slack... and upload it.
Mar 18, 2024, 6:33 PM
The error seems related to the image and nothing else.
Mar 18, 2024, 6:33 PM
I mean at this point. Probably the best solution
Mar 18, 2024, 6:33 PM
Yeah...
Mar 18, 2024, 6:34 PM
Don't get stuck because of an image.
Mar 18, 2024, 6:34 PM
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..
Mar 18, 2024, 6:38 PM
Thank you for the support again!
Mar 18, 2024, 6:38 PM
it might be a permission issue
Mar 18, 2024, 6:41 PM
good to know
Mar 18, 2024, 6:41 PM
happy codding
Mar 18, 2024, 6:41 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?