Issue with assets not showing up in the Sanity studio after being uploaded to Firebase Cloud Storage.
I can see the issue! When you use client.assets.upload(), you're creating an asset document in Sanity, but that asset isn't automatically connected to any of your content documents - it's just sitting in your asset library. This is why you're getting a CDN link back but not seeing it appear in your Studio's main content views.
The Problem
The asset upload method creates standalone asset documents in your Content Lake. These assets exist, but they're not referenced by any of your content documents, so they won't show up in your regular document views in Studio.
Solutions
Option 1: Create a Document that References the Asset
After uploading the asset, create or update a document that references it:
try {
const asset = await client.assets.upload("image", thumbnailBuffer, {
contentType: metaData.contentType,
filename: 'your-filename.jpg' // Adding filename helps with identification
});
logger.log("Returned asset", asset);
// Now create a document that uses this asset
await client.create({
_type: 'yourDocumentType',
title: 'Firebase uploaded image',
image: {
_type: 'image',
asset: {
_type: 'reference',
_ref: asset._id
}
}
});
logger.log("Document created with image reference!");
} catch (error) {
logger.error(error);
}Option 2: View Assets Directly
If you want to see all uploaded assets (even orphaned ones), you can:
- Install sanity-plugin-media which gives you a dedicated asset browser
- Use the Vision plugin in Studio and query:
*[_type == "sanity.imageAsset"]to see all image assets - Access the Media Library if you're on an Enterprise plan
Option 3: Update an Existing Document
If you want to attach the uploaded image to an existing document:
const asset = await client.assets.upload("image", thumbnailBuffer, {
contentType: metaData.contentType
});
await client.patch('document-id-here')
.set({
image: {
_type: 'image',
asset: {
_type: 'reference',
_ref: asset._id
}
}
})
.commit();Additional Tips
- Add a
filenameoption to your upload to make assets easier to identify - Consider adding
sourcemetadata to track that these came from Firebase - The asset CDN link works immediately, but the asset needs to be referenced by a document to appear in your content views
The key takeaway: assets are separate entities from your content documents. You need to create that connection explicitly for them to show up in your Studio's document views.
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.