I follow this link to upload images to firebase storage, the images is uploaded in storage. However to view the images I've to manually generate the access token inside the image in storage. I'm hoping is there any idea to auto generate the access token for that particular image from my code.
Below are my code to upload image
$factory = (new Factory)->withServiceAccount(__DIR__.'/myfirebase.json');
$storage = $factory->createStorage();
$image = $request->file('image');
$localfolder = public_path('firebase-temp-uploads') .'/';
if (!file_exists($localfolder)) {
mkdir($localfolder, 0777, true);
}
$extension = $image->getClientOriginalExtension();
$file = $shopId. '.' . $extension;
if ($image->move($localfolder, $file)) {
$uploadedfile = fopen($localfolder.$file, 'r');
$storage->getBucket()->upload($uploadedfile, [
'name' => 'categories/'.$file,
// 'predefinedAcl' => 'PUBLICREAD',
]);
unlink($localfolder . $file);
}
I try to used 'predefinedAcl' => 'PUBLICREAD'
but it's not working and also manually created access token is not available anymore in the storage