I'm having a trouble with uploading image to Firestore Storage. Here is the problem:
Fatal error: Uncaught Google\Cloud\Core\Exception\ServiceException:
{
"error": {
"code": 403,
"message": "firebase-adminsdk-5jy3x@carimakan-bd835.iam.gserviceaccount.com does not have storage.objects.create access to images/test.jpeg.",
"errors": [
{
"message": "firebase-adminsdk-5jy3x@carimakan-bd835.iam.gserviceaccount.com does not have storage.objects.create access to images/test.jpeg.",
"domain": "global",
"reason": "forbidden"
}
]
}
} in C:\xampp\htdocs\cariMakan\vendor\google\cloud-core\src\RequestWrapper.php:368
Stack trace:
#0 C:\xampp\htdocs\cariMakan\vendor\google\cloud-core\src\RequestWrapper.php(207): Google\Cloud\Core\RequestWrapper->convertToGoogleException(Object(GuzzleHttp\Exception\ClientException))
#1 C:\xampp\htdocs\cariMakan\vendor\google\cloud-core\src\Upload\MultipartUploader.php(44): Google\Cloud\Core\RequestWrapper->send(Object(GuzzleHttp\Psr7\Request), Array)
#2 C:\xampp\htdocs\cariMakan\vendor\google\cloud-storage\src\Bucket.php(294): Googl in C:\xampp\htdocs\cariMakan\vendor\google\cloud-core\src\RequestWrapper.php on line 368
I have search on the internet that I need to give permission to the users. I give it like this
but still no luck.
Here is my code:
$this->bucket = $this->storage->bucket($ref);
$this->bucket->upload(
file_get_contents($data['tmp_name']),
[
'name' => $data['name']
]
);
How to fix it?
