设置好代理
1.搭建nodejs测试项目
mkdir hello-express
cd hello-express/
npm init
yarn add express
2.添加
yarn add @google-cloud/storage
npm start
gcloud init
gcloud auth application-default login
修改后的代码
// Imports the Google Cloud client library
const { Storage } = require(’@google-cloud/storage’);
const path = require(‘path’);
const config=require(’./google-cloud-json.json’)
console.log(config)
// Creates a client
const storage = new Storage(config);
/**
- TODO(developer): Uncomment the following lines before running the sample.
*/
// const bucketName = ‘Name of a bucket, e.g. my-bucket’;
const filename = path.join(__dirname, ‘/file.txt’);
const bucketName = ‘test-69f62.appspot.com’;
var test = () => {