I have run into this problem and cant find a simple working php example online that can set the object cache-control while uploading to google cloud storage. I know its a setMetadata on object, but I am lost how to do it. using gsutil doesnt cut it because it is not dynamic for a web app.
So far, this is what I have but the setMetadata line throws errors. Can anyone please help correct that line? Note that authorisation token already obtained before the below
$file = "xxx.html";
$infotowrite = "999";
$service = new Google_Service_Storage($client);
$obj = new Google_Service_Storage_StorageObject();
$obj->setName($file);
$obj->setMetadata(['cacheControl' => 'public', 'max-age' => '6000']);
$results = $service->objects->insert(
$bucket_name,
$obj,
['name' => $file, 'mimeType' => 'text/html', 'data' => $infotowrite, 'uploadType' => 'media']
);