Error in create object permission to Google Storage Bucket programmatically.

I have created a Bucket using UI of google console. I want to upload some object in the Bucket programmatically. I've checked the documentation from Google. https://cloud.google.com/storage/docs/object-basics#upload

$storage = new StorageClient();
$file = fopen($source, 'r');
$bucket = $storage->bucket($bucketName);
$object = $bucket->upload($file, [
    'name' => $objectName
]);
printf('Uploaded %s to gs://%s/%s' . PHP_EOL, basename($source), $bucketName, $objectName);

Problem is, Returning an error regarding to the permission.

{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "[email protected]erviceaccount.com does not have storage.objects.create access to object kjs-lms/0.mp3."
}
],
"code": 403,
"message": "[email protected]erviceaccount.com does not have storage.objects.create access to object kjs-lms/0.mp3."
}
}

I tried to grant the permission in IAM Roles but still same error.

0 Comment

NO COMMENTS

LEAVE A REPLY

Captcha image