對不起noob問題,但這是一個我似乎無法解決的問題。我有一個laravel腳本將文件公開上傳到谷歌存儲桶,它正常工作。問題是我上傳的對象就在桶內,它應該放在桶內的一個目錄中。 e.g鬥 - 的/ dev桶/,正確的目錄 -/DEV-桶/媒體/下面是我的腳本PHP:將公共文件上傳到Google存儲桶中的文件夾
$client = new \Google_Client();
$credential = new \Google_Auth_AssertionCredentials(
'[email protected]',
['https://www.googleapis.com/auth/devstorage.full_control'],
file_get_contents(storage_path().'xxxxx.p12')
);
$client->setAssertionCredentials($credential);
// this access control is for project owners
$ownerAccess = new \Google_Service_Storage_ObjectAccessControl();
$ownerAccess->setEntity('project-owners-' . 'xxxxxxxxxxx');
$ownerAccess->setRole('OWNER');
// this access control is for public access
$readerAccess = new \Google_Service_Storage_ObjectAccessControl();
$readerAccess->setEntity('allUsers');
$readerAccess->setRole('READER');
$storage = new \Google_Service_Storage($client);
$obj = new \Google_Service_Storage_StorageObject();
$obj->setName($stageFileName);
$obj->setAcl([$ownerAccess, $readerAccess]);
$storage->objects->insert(
Config::get('constants.bucket'),
$obj,
[
'name' => $stageFileName,
'data' => file_get_contents($stageFile),
'uploadType' => 'media',
]
);
是否有關於如何把對象的桶內目錄內的選項?
非常感謝。我到處尋找這個。 – Lomse