[英]php deleting files from google storage using google-api-php-client
嘗試下面的代碼從Google存儲空間中刪除文件,但出現錯誤“發生錯誤:(刪除)缺少必需的參數:'對象'”。 我正在像這樣發送fileId $ fileId = 1458180875815000。
$ google-api-php-client:-獲取Google服務
// code for delete
$bucketName = "bucketname";
$googleServiceStorage = new Google_Service_Storage($this->client);
//$googleServiceStorage = new Google_Service_Storage_StorageObject();
try
{
$googleServiceStorage->objects->delete($bucketName,$companyId,
[
'object' => $companyId."/".$objectName,
'generation' => $fileId,
'alt' => "media"
]
);
//$bucketName,$companyId,$objectName,$fileId);
}
catch (Exception $e)
{
print "An error occurred: " . $e->getMessage();
}
}
這是我從GCS刪除文件的方式
$bucket = 'my_main_bucket';
$file = 'path/to/file/image.jpg';
$this->service = new Google_Service_Storage($this->client);
try
{
$this->service->objects->delete($bucket, $file);
}
catch (Google_Service_Exception $e)
{
syslog(LOG_ERR, $e);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.