-1
我是Google雲端存儲的新用戶,請耐心等待。簡單更新Google雲端存儲中的文字內容
我正在嘗試創建一個文件編輯器,它從GCS獲取非二進制文件並將其保存回來。
我正在使用google-api-php-client。我一直在使用API進行很多實驗,瀏覽過,但我找不到合適的答案。
<?php
class GCS_Driver {
/** @var Google_Service_Storage $driver */
public $driver;
/** @var string $bucket */
public $bucket;
public function updateObject($objectPath,$content) {
$updated = false;
try {
$postBody = new Google_Service_Storage_StorageObject();
$updated = $this->driver->objects->patch($this->bucket,$objectPath,$postBody,array(
'data' => $content // I know this is wrong, I am just showing the idea I am looking for to overwrite the content
));
} catch (Exception $ex) {
// error log
return false;
}
if (!$updated) {
// error log
return false;
}
return true;
}
}
任何提示將不勝感激。