I need to create and share a bucket in gcloud storage using Node.js Client.
This is my code
Bucket.createNewBucket = function (request, callBack) {
// code for create a new bucket
var bucketName = request.body.bucketName;
gcs.createBucket(bucketName, function (err, bucket) {
if (!err) {
console.log("created bucket successfully");
var bucketadded = gcs.bucket(bucketName);
bucketadded.acl.add({
entity: 'testmail@gmail.com',
role: 'READER'
}, function (err, aclObject) {
if (!err) {console.log("acl added successfully");
}else{
console.log(err);
}
});
callBack(null, true);
return;
} else {
callBack("Error with bucket creation. Error: " + err, true);
return;
}
});
};
Using this code, I am successfully able to create a bucket in google storage. But I can't add acl permission to the bucket.
i got error like this
{ [ApiError: Invalid Value]
errors: [ { domain: 'global', reason: 'invalid', message: 'Invalid Value' } ],
code: 400,
message: 'Invalid Value',
response: undefined }
use this
entity: 'user-testmail@gmail.com'
instead of
entity: 'testmail@gmail.com'