Sanity image upload failing with "Upload could not be completed" error

10 replies
Last updated: Dec 22, 2021
Hello. I just tried uploading a few images locally and on my hosted Sanity Studio, however every time I do I am receiving the following error:
Upload failed
The upload could not be completed at this time
I checked the Sanity Status page and looks like everything is OK.
AI Update

I understand how frustrating this is! The generic "Upload failed - The upload could not be completed at this time" error can have several different causes. Since you've checked the Sanity Status page and everything looks operational, let me walk you through the most common causes and solutions:

1. Check Your Image Schema Configuration

Based on similar error patterns, the most common cause is having invalid options in your image field's metadata array. According to the image metadata documentation, there are three metadata fields that are always included automatically and will cause upload errors if you try to specify them:

  • dimensions (width and height)
  • hasAlpha (whether the image has an alpha channel)
  • isOpaque (whether the image is fully opaque)

Check your schema - if you have an image field with a metadata configuration like this:

options: {
  metadata: ['dimensions', 'location', 'exif'], // ❌ 'dimensions' will cause errors
}

You need to remove dimensions, hasAlpha, or isOpaque from the array. The valid values are only:

  • 'exif' - Camera and photo information
  • 'location' - GPS coordinates
  • 'palette' - Color information (included by default)
  • 'lqip' - Low Quality Image Placeholder (included by default)
  • 'blurhash' - Compact image representation (included by default)

The fix:

options: {
  metadata: ['location', 'exif'], // ✅ Only valid optional fields
}

2. CORS Configuration

If the schema isn't the issue, check your CORS origins settings. This is especially important for hosted Studios or custom domains:

  1. Go to manage.sanity.io
  2. Select your project
  3. Navigate to Settings > API > CORS Origins
  4. Add your Studio's URL (e.g., https://your-studio.sanity.studio)
  5. Check the "Allow credentials" checkbox
  6. For local development, also add http://localhost:3333 (or your local port)

3. Check Browser Console for Specific Errors

Open your browser's developer tools (F12) and check the Console and Network tabs. Look for specific error messages that will tell you exactly what's failing. If you see an error mentioning meta validation or something like "must be one of [location, exif, image, palette, lqip, blurhash, none]", that confirms it's a schema metadata configuration issue.

4. Other Potential Causes

  • File size/type: Try uploading a small, simple JPEG to rule out file-specific issues
  • Browser issues: Test in an incognito window or different browser
  • Authentication: Verify your token has correct permissions if using custom auth
  • Network restrictions: Check if your network or firewall is blocking the upload requests

Quick Diagnostic Steps

  1. Check browser console first - This will give you the most specific error message
  2. Review your schema - Look for any image fields with metadata arrays
  3. Test with a fresh project - Try uploading to a new empty project to rule out project-specific issues

Since this is happening both locally and on your hosted Studio, a schema configuration issue (particularly with the metadata array) is the most likely culprit, but the browser console will tell you for certain. Let me know what you see in the console and I can help narrow it down further!

Show original thread
10 replies
Hi Brent. Is there any additional information in the console?
Hi
user A
, sorry I forgot to add that to the original message.
{
    "response": {
        "body": {
            "statusCode": 400,
            "error": "Bad Request",
            "message": "child \"meta\" fails because [\"meta\" at position 0 fails because [\"0\" must be one of [location, exif, image, palette, lqip, blurhash, none]]]",
            "validation": {
                "source": "query",
                "keys": [
                    "meta.0"
                ]
            }
        },
        "url": "<https://xxxxxx.api.sanity.io/v1/assets/images/production?tag=sanity.studio.asset.upload&filename=brooke-cagle-Uduc5hJX2Ew-unsplash.jpg&meta=dimensions&meta=location&meta=exif>",
        "method": "POST",
        "headers": {
            "content-length": "248",
            "content-type": "application/json; charset=utf-8",
            "etag": "W/\"f8-CqKInPwEck24vFlC5Ogq0g/OQBQ\""
        },
        "statusCode": 400,
        "statusMessage": ""
    },
    "statusCode": 400,
    "responseBody": "{\n  \"statusCode\": 400,\n  \"error\": \"Bad Request\",\n  \"message\": \"child \\\"meta\\\" fails because [\\\"meta\\\" at position 0 fails because [\\\"0\\\" must be one of [location, exif, image, palette, lqip, blurhash, none]]]\",\n  \"validation\": {\n    \"source\": \"query\",\n    \"keys\": [\n      \"meta.0\"\n    ]\n  }\n}"
}
To me it looks like a possible issue with my options.metadata array:

options: {
    metadata: ['dimensions', 'location', 'exif'],
 },
It was ‘dimensions’… 🙄
Ahh, good find! Glad you got things working. 🙌
Haha yea, I knew that was a default but I guess I didn’t think it would cause it to break if I included. Oh well. Lesson learned. Thanks for your quick response/help. Have a great day!
Somewhere in our docs I seem to recall seeing all of the metadata options listed. I’ll need to track that down and ensure it’s correct. Appreciate you bringing this up. Have a great day as well!
Ahh, right at the top here . I’ll make sure this is correct or corrected.
Thank you! Yea that’s where I found it originally too.
I guess the added message could be added / updated to “Always included” something about not including it…
since it’s always included

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?