2
在GAE云平台,我可以使用它来如何在本地主机上模拟本地应用程序引擎启动器的默认桶?
file_put_contents('gs://#default#/hello.txt', 'Hello');
或
CloudStorageTools::getDefaultGoogleStorageBucketName()
如何模拟云存储桶在我的本地应用程序启动器返回斗的名字吗?
在GAE云平台,我可以使用它来如何在本地主机上模拟本地应用程序引擎启动器的默认桶?
file_put_contents('gs://#default#/hello.txt', 'Hello');
或
CloudStorageTools::getDefaultGoogleStorageBucketName()
如何模拟云存储桶在我的本地应用程序启动器返回斗的名字吗?
开发服务器将使用本地文件系统自动模拟云存储。桶不需要首先创建,因为这是在您第一次写入时自动完成的。唯一的区别是在本地开发服务器上CloudStorageTools :: getDefaultGoogleStorageBucketName()将在生产中返回字符串'app_default_bucket',默认存储桶名称通常是'your-app-id.appspot.com',但出于实际的目的,这使得没有不同。
下面的代码将工作以同样的方式在两个开发和生产线:
// Get default bucket name
$defaultBucket = CloudStorageTools::getDefaultGoogleStorageBucketName();
// Write something to the default bucket
file_put_contents('gs://' . $defaultBucket . '/some_file.txt', 'Hello World');
// Read something back from the file
echo file_get_contents('gs://' . $defaultBucket . '/some_file.txt');
PROD上我试过,但我认为$ defaultBucket没有返回。是否因为谷歌提供每个应用程序引擎帐户的默认存储? –
这是一个很好的问题!在生产中,默认存储桶不会自动创建。要设置它,您仍然需要转到https://appengine.google.com - > - >管理 - >应用程序设置 - >云集成(页面底部)的旧控制台。 –
Adam