chichi
chichi

Reputation: 3302

firebase storage: uploading jpg casuing Could not load the default credentials. on Node.js

const { initializeApp } = require("firebase-admin/app");
const { getStorage } = require("firebase-admin/storage");

const firebaseConfig = {
  apiKey: "ajsoidjof",
  authDomain: "asodijfo",
  projectId: "sihfiasd",
  storageBucket: "sadjofjosad",
  messagingSenderId: "2039023423",
  appId: "saoijdofijo3ijo2",
  measurementId: "sijdofijeadsf",
};

initializeApp(firebaseConfig);


  const bucket = getStorage().bucket();
  bucket.upload("./1.jpg");

This causes Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information. error. And, how can I upload the 1.jpg to just the main storage folder?

Upvotes: 0

Views: 31

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599081

You're using the Firebase Admin SDK for Node.js, but then trying to initialize it with the configuration data for a client-side SDK. That won't work, so you'll either have to initialize the Admin SDK as shown here or use the client-side Node.js SDK.

Upvotes: 1

Related Questions