✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Issue with assets not showing up in the Sanity studio after being uploaded to Firebase Cloud Storage.

11 replies
Last updated: Aug 21, 2023
I am building a firebase cloud action , when an image is uploaded in the storage an asset upload to sanity will take placeWhile doing this i am not getting any error, even the cdn link of the asset uploaded is getting returned but it is not getting shown anywhere in the studio


const metaData = {contentType}
    await bucket.file(thumbFilePath).save(thumbnailBuffer,{
        metadata:metaData
    })
    try {
        const data = await client.assets.upload("image", thumbnailBuffer, { contentType: metaData });
        logger.log("Returned asset", data);
        logger.log("Thumbnail Uploaded!");
    } catch (error) {
        logger.error(error);
    } finally {
        logger.log("Over");
    }
    
    return
Any help
Thanks in advance
Aug 21, 2023, 2:26 PM
You can use the Media Browser Plugin to manage your assets.
Aug 21, 2023, 2:45 PM
I am already using itBut still it is not visible
Aug 21, 2023, 2:49 PM
Is the CDN link being returned by the API accessible to you?
Aug 21, 2023, 2:54 PM
Yes , I can view the image using the cdn link
Aug 21, 2023, 2:54 PM
Does the project ID in the CDN url match the one set for the Studio where you have installed the Media browser plugin?
Aug 21, 2023, 3:00 PM
Aug 21, 2023, 3:01 PM
import {defineConfig} from 'sanity'
import {deskTool} from 'sanity/desk'
import {visionTool} from '@sanity/vision'
import {schemaTypes} from './schemas'
import { media } from 'sanity-plugin-media'

export default defineConfig({
  name: 'default',
  title: 'CLOUD-FUNCTION-BUCKET',

  projectId: '6ydkcei8',
  dataset: 'trial',

  plugins: [deskTool(), visionTool(),media()],

  schema: {
    types: schemaTypes,
  },
})
Aug 21, 2023, 3:01 PM
This is my config file
Aug 21, 2023, 3:02 PM
I am not a 100% sure but I wonder if the issue is the
dataset
? The one in the URL looks like it is pointing to
production
but the config file is pointing to
dataset: 'trial'
? Can you set
dataset: 'production'
in your config file and see if that helps?
Aug 21, 2023, 3:04 PM
Yes sorry for the overlookingI was continuously changing the dataset of sanity.cli.js instead of the config one
Thanks for pointing that
Little little typos
🥲
Aug 21, 2023, 3:07 PM
Thanks
Aug 21, 2023, 3:07 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?