Set Cache-Control php client on Google Cloud Storage Object

后端 未结 1 1699
耶瑟儿~
耶瑟儿~ 2021-01-22 18:09

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 setMet

相关标签:
1条回答
  • 2021-01-22 18:40

    I think you want to call the setCacheControl function.

    Here is a working example:

    $bucket_name = 'my-bucket';
    $file = "xxx.html";
    $infotowrite = "999";
    $service = new Google_Service_Storage($client);
    $obj = new Google_Service_Storage_StorageObject();
    $obj->setName($file);
    $obj->setCacheControl('public, max-age=6000');
    $results = $service->objects->insert(
            $bucket_name,
            $obj,
            ['name' => $file, 'mimeType' => 'text/html', 'data' =>   $infotowrite, 'uploadType' => 'media']
    );
    
    0 讨论(0)
提交回复
热议问题