Firebase“与Google Cloud集成”文档是否已过时?

时间:2018-12-05 20:26:54

标签: firebase google-cloud-storage

问题

'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

1 个答案:

答案 0 :(得分: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文档页面上的发送反馈按钮提交了以下反馈。

相关问题