【问题标题】:Is the Firebase 'Integrate with Google Cloud' Documentation Outdated?Firebase“与 Google Cloud 集成”文档是否已过时?
【发布时间】:2023-04-03 19:39:01
【问题描述】:

问题

'Integrate with Google Cloud' documentation 指示使用通用 google-cloud 库。

var gcloud = require('google-cloud');

但是,在安装 npm install --save google-cloud 时,以下消息显示不推荐使用通用库。

google-cloud 软件包已被弃用。我们强烈建议安装单独的 API 包,例如 @google-cloud/storage。有关 Google Cloud Platform API 特定包的列表,请访问https://cloud.google.com/nodejs/docs/reference/libraries

【问题讨论】:

  • 您的问题会自行回答,但这并不是 Stack Overflow 的工作方式。请将问题编辑为仅是一个问题,然后您可以使用您的答案来回答它,并将其标记为正确。否则,这个问题无法正确结束。
  • 谢谢,我已经相应调整了。

标签: firebase google-cloud-storage


【解决方案1】:

解决方案

关注npmjs documentation for @google-cloud/storage

// Imports the Google Cloud client library
const {Storage} = require('@google-cloud/storage');

// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';

// Creates a client
const storage = new Storage({
  projectId: projectId,
});

// The name for the new bucket
const bucketName = 'my-new-bucket';

// Creates the new bucket
storage
  .createBucket(bucketName)
  .then(() => {
    console.log(`Bucket ${bucketName} created.`);
  })
  .catch(err => {
    console.error('ERROR:', err);

我已通过 Firebase 文档页面上的发送反馈按钮提交了以下反馈。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-10
    • 2016-12-08
    • 2020-03-21
    • 2019-03-07
    • 1970-01-01
    • 2019-07-08
    • 2020-07-04
    • 2013-10-04
    相关资源
    最近更新 更多