dom*_*ber 1 php google-app-engine google-cloud-storage google-api-php-client
我目前正在尝试将云存储文件重命名和/或移动到另一个名称/位置,但我无法让它工作.我使用https://github.com/google/google-api-php-client作为客户端,上传工作正常:
...
$storageService = new \Google_Service_Storage( $client )
$file = new \Google_Service_Storage_StorageObject()
$file->setName( 'test.txt' );
$storageService->objects->insert(
$bucketName,
$file,
array(
'name' => $filename,
'data' => file_get_contents( $somefile )
)
);
...
Run Code Online (Sandbox Code Playgroud)
所以我试图通过$ storageObject-> objects-> update()方法更改文件名,但我找不到任何关于此的文档.我使用$ storageService-> objects-> get($ bucketName,$ fileName)来获取我想要重命名的特定文件(使用$ file-> setName()),但似乎我无法将文件传递给对象 - >更新功能.我做错了吗?
好吧,似乎我无法直接重命名文件(如果我错了请纠正我),我只能更新元数据.我设法通过将文件复制到新的文件名/目标,然后删除旧文件来使其工作.我成功地使用了$ storageService-> objects-> copy和$ storageService-> objects-> delete.这感觉不对,但至少它有效.
归档时间: |
|
查看次数: |
3071 次 |
最近记录: |