【发布时间】:2017-11-14 12:08:48
【问题描述】:
我只是想做一个很简单的file_get_contents('gs://[bucket][file]');
我在本地运行时收到此错误。"\google\appengine\ext\cloud_storage_streams\CloudStorageStreamWrapper::stream_open" call failed。
但是,当我在生产环境中运行它时,它运行良好。
我知道我在设置中遗漏了一些东西,但我不确定是什么。
我已经设置了项目gcloud config set project PROJECT_ID,设置了账号gcloud config set account ACCOUNT,运行gcloud auth login。关于我在这里的设置中缺少什么的任何想法?
我运行了composer install,composer require google/cloud,在包含use Google\Cloud\Storage\StorageClient; 时没有收到任何错误我创建了service-account-keyfile 作为存储桶的所有者。将所有者设置为完全权限。跑这段代码...
require __DIR__ . '/vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$storage = new StorageClient([
'keyFilePath' => __DIR__ .'/../keys/appdocs-com.json',
]);
echo file_get_contents('gs://[myBucket][myFile]');
我仍然收到...streamWrapper::stream_open" call failed
我什至尝试了服务构建器方法。
require __DIR__ . '/vendor/autoload.php';
use Google\Cloud\ServiceBuilder;
use Google\Cloud\Storage\StorageClient;
$gcloud = new ServiceBuilder([
'keyFilePath' => __DIR__ .'/../keys/appdocs-com.json',
'projectId' => 'appdocs-com',
]);
$storage = $gcloud->storage();
$bucket = $storage->bucket('test-appdocs-sendgrid-inbound');
$object = $bucket->object('4/envelope.json');
$stream = $object->downloadAsStream();
echo $stream->getContents();
这会返回
Fatal error: Uncaught exception 'Google\Cloud\Core\Exception\ServiceException' with message 'No system CA bundle could be found in any of the the common system locations. PHP versions earlier than 5.6 are not properly configured to use the system's CA bundle by default. In order to verify peer certificates, you will need to supply the path on disk to a certificate bundle to the 'verify' request option: http://docs.guzzlephp.org/en/latest/clients.html#verify. If you do not need a specific certificate bundle, then Mozilla provides a commonly used CA bundle which can be downloaded here (provided by the maintainer of cURL): https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt. Once you have a CA bundle available on disk, you can set the 'openssl.cafile' PHP ini setting to point to the path to the file, allowing you to omit the 'verify' request option. See http://curl.haxx.se/docs/sslcerts.html for more information.' in /Users/thom/Engine/appdocs-com/vendor/google/cloud-core/RequestWrapper.php:241 Stack trac in /Users/thom/Engine/appdocs-com/vendor/google/cloud-core/RequestWrapper.php on line 241
我在php55 有我的runtime。这会阻止我使用StorageClient 或serviceBuilder
【问题讨论】:
-
您应该确保您的开发环境中的 gcloud 和 php 安装和配置与生产环境匹配
-
如果我使用
gcloud app deploy从命令行部署那个应用程序,它们不应该匹配吗?
标签: php google-app-engine google-cloud-platform google-cloud-storage