如何使用Google Cloud Storage for PHP? [英] How to use Google Cloud Storage for PHP?

查看:462
本文介绍了如何使用Google Cloud Storage for PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我遵循关于如何在其网站上使用GCS的指南: https:/ /developers.google.com/appengine/docs/php/googlestorage/

So ive followed the guide on how to use GCS on their site: https://developers.google.com/appengine/docs/php/googlestorage/

但下面的代码不起作用。

But the following code does not work. I cannot access my bucket, and the CloudStorageTools is not even found.

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

// check if GCS bucket if writable
$my_bucket = 'gs://my_bucket/';
$check1 = is_writable($my_bucket); //returns nothing

class_exists("CloudStorageTools"); //returns false

我还将google_app_engine.allow_include_gs_buckets添加到php.ini文件中。仍然不支持GCS。

I also added google_app_engine.allow_include_gs_buckets into the php.ini file. Still no support for GCS.

任何人都有一些他们可以分享的运行代码吗?

Anyone have some running code they could share?

认为它可能与设置到你的存储桶的权限有关。请确保您已添加您的应用程序帐户电子邮件应用程序设置 - >服务帐户名称。

I think it may have something to do with permissions set to your bucket. Make sure you added your app account email Application Settings -> Service Account Name.

我移动我的应用程序没有问题,并使用Smarty写入和包括在存储桶中。我没有声明:

I ported my app with no issues and using Smarty to write into and include from the bucket. I did not have to declare:

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

,并且应用程序读取并写入存储区而不会出现问题。

and the app reads and writes to the bucket with no problems.

然而,我有一些WordPress移植的问题,虽然存储桶已经存在并且具有正确的设置访问权限,但由于某种原因,应用程序抛出致命错误,我可以在应用程序日志中看到它,该应用程序是试图通过gs:// wrapper访问云存储。

I have had however issues with some WordPress porting, when although the bucket existed and had properly setup access permission, for some reason app throws a Fatal Error and I can see it in the app logs, that application was trying to access the cloud storage via gs:// wrapper.

希望有帮助。

这篇关于如何使用Google Cloud Storage for PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆