【问题标题】:Unable to rename Google Cloud Storage object无法重命名 Google Cloud Storage 对象
【发布时间】:2023-03-12 04:01:01
【问题描述】:

我无法重命名 Google Cloud Storage 对象,以下是我尝试使用的简单代码,但是

require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;

$core_url = 'gs://store.lonel.com/F9BEA944A8543F.jpg';

 $ctx = [
  'gs' => [
    'enable_cache' => true,
    'enable_optimistic_cache' => true,
    'read_cache_expiry_seconds' => 300,
  ]
];
$ctx_res = stream_context_set_default($ctx);
if (false == rename($core_url, 'gs://store.lonel.com/MMMF9BEA944A8543F.jpg',$ctx_res))
{
  die('Could not rename.');
}else{
    echo 'Done renaming';
}

我已使用 Google Cloud Storage API 请求插入对象。

输出:

警告:无法重命名:gs://store.lonel.com/MMMF9BEA944A8543F.jpg。 云存储错误:在 C:\Program 中未找到 Files\Google\google_appengine\php\sdk\google\appengine\ext\cloud_storage_streams\CloudStorageRenameClient.php 在第 77 行

【问题讨论】:

标签: php google-app-engine google-cloud-storage


【解决方案1】:

您是否在本地运行此 AppEngine 应用并尝试重命名 Google Cloud Storage 中的真实对象?当您在本地运行 AppEngine 开发服务器时,AppEngine 会模拟连接到 Google Cloud Storage,但它不会与真实事物进行通信。您可能正在尝试访问存在于 Google Cloud Storage 中但不存在于本地模拟环境中的对象。

请注意,通过 Google API Python 客户端(您没有使用)访问 Google Cloud Storage 的情况并非如此,该客户端与 App Engine 分开,并且会联系真正的 Google Cloud Storage,而不管它是哪个 App Engine 环境跑进去。

【讨论】:

  • 它在服务器 AppEngine 云存储上工作......所有大多数功能都在本地工作,所以我在本地服务器中尝试了 rename() 函数。谢谢。
猜你喜欢
  • 2015-01-25
  • 2014-09-08
  • 2019-03-31
  • 2021-04-14
  • 2018-02-04
  • 1970-01-01
  • 1970-01-01
  • 2013-07-15
  • 2014-11-25
相关资源
最近更新 更多