skip to Main Content

Setting up tests for cleaning up local Firebase Emulator environment and need to clear all buckets. For Gcloud implementation there’s a method but can’t find equivalent for Firebase Storage. I’ve tried to cast as Storage from @google-cloud/storage but that doesn’t work. Any workaround?

2

Answers


  1. Chosen as BEST ANSWER

    Thanks for the push in the right direction, Frank. I'm using server-side Firebase SDKs for NodeJS.

    Below did work:

    import { Storage } from '@google-cloud/storage';
    
    const storageGcp = new Storage();
    const [buckets] = await storageGcp.getBuckets();
    

    As getBuckets() doesn't exist on Firebase's Storage object, returned from getStorage(), below didn't work:

    import { getStorage } from 'firebase-admin/storage';
    
    const storageFb = new getStorage(); // Also returns Storage
    const [buckets] = await storageGcp.getBuckets();
    

  2. The client-side Firebase SDKs only know about a single bucket, and have now way to list all buckets in a project.

    The server-side Firebase SDKs for Cloud Storage are mostly simple wrappers around the GCP SDKs for their platforms, so should give you access to all APIs that those have. If you can’t get that to work, edit your question to show what you tried (which would also answer the question of what language you’re using).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search