Firebase存储:上传JPG CASUINE无法加载默认凭据。在node.js上

发布于 2025-02-08 15:32:42 字数 624 浏览 2 评论 0原文

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");

这导致错误:无法加载默认凭据。浏览到https://cloud.google.com/docs/authentication/getting-started以获取更多信息。错误。而且,如何将1.jpg仅将其上传到主要存储文件夹?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流心雨 2025-02-15 15:32:42

您正在为Node.js使用firebase admin sdk,但随后尝试使用客户端SDK的配置数据初始化它。那将无法使用,因此您要么必须初始化Admin SDK,如所示在这里或使用 client noreferrer”> client-side node.js sdk

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文