【发布时间】:2015-11-20 13:59:18
【问题描述】:
我遇到了这个问题,在网上找不到一个可以在上传到谷歌云存储时设置对象缓存控制的简单工作 php 示例。我知道它是对象上的 setMetadata,但我不知道该怎么做。使用 gsutil 并没有减少它,因为它对于 Web 应用程序来说不是动态的。
到目前为止,这就是我所拥有的,但 setMetadata 行会引发错误。任何人都可以帮助纠正那条线吗?请注意,在下面之前已经获得了授权令牌
$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']
);
【问题讨论】:
标签: php google-cloud-storage cache-control