$file = 'gs://myapp.appspot.com/storage.json';
file_put_contents($file, $array);
$response = file_get_contents($file);
当我在本地运行 appengine 时,这工作正常,但在生产环境中不起作用。欢迎任何建议。
可能是存储桶名称错误。尝试这样的事情,在运行时查找存储桶名称。
use google'appengine'api'cloud_storage'CloudStorageTools;
$bucket = CloudStorageTools::getDefaultGoogleStorageBucketName();
$file = "gs://$bucket/storage.json";
file_put_contents($file, $array);
$response = file_get_contents($file);