从 Cloud Functions 执行任何 Google Cloud Storage 操作时出现错误。我不断收到错误[project-id]@appspot.gserviceaccount.com does not have storage.buckets.get
。我给了服务管理员不同的角色,包括,editor
但似乎不起作用。storage admin
storage object admin
下面是测试功能。
exports.test = async (req, res) => {
const {Storage} = require('@google-cloud/storage');
// Creates a client
const storage = new Storage();
// Gets the ACL for the bucket
const [acls] = await storage.bucket('sharedbox').acl.get();
acls.forEach(acl => {
console.log(`${acl.role}: ${acl.entity}`);
});
};