对不起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