php - How do I simulate the default Bucket for local app engine launcher on localhost? -
on gae cloud platform can use through
file_put_contents('gs://#default#/hello.txt', 'hello');
or return bucket name
cloudstoragetools::getdefaultgooglestoragebucketname()
how simulate cloud storage bucket in localhost app launcher?
the development server automatically simulate cloud storage using local file system. buckets don't need created first done automatically first time write them. difference on local development server cloudstoragetools::getdefaultgooglestoragebucketname() return string 'app_default_bucket' while in production default bucket name 'your-app-id.appspot.com', practical purposes makes no difference.
the following code work same way on both dev , prod:
// default bucket name $defaultbucket = cloudstoragetools::getdefaultgooglestoragebucketname(); // write default bucket file_put_contents('gs://' . $defaultbucket . '/some_file.txt', 'hello world'); // read file echo file_get_contents('gs://' . $defaultbucket . '/some_file.txt');
Comments
Post a Comment