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

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

问题描述

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 googleappengineapicloud_storageCloudStorageTools;

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

class_exists("CloudStorageTools"); //returns false

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.

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 googleappengineapicloud_storageCloudStorageTools;

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

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.

Hope that helps.

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

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