ShivarajRH ShivarajRH - 6 months ago 75
PHP Question

Unable to rename Google Cloud Storage object

I am Unable to rename Google Cloud Storage object, Following is the simple code i tried with, but

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

$core_url = 'gs://';

$ctx = [
'gs' => [
'enable_cache' => true,
'enable_optimistic_cache' => true,
'read_cache_expiry_seconds' => 300,
$ctx_res = stream_context_set_default($ctx);
if (false == rename($core_url, 'gs://',$ctx_res))
die('Could not rename.');
echo 'Done renaming';

I have inserted object using Google Cloud Storage API request.


Warning: Unable to rename: gs://
Cloud Storage Error: NOT FOUND in C:\Program
on line 77


Are you running this AppEngine app locally and trying to rename a real object in Google Cloud Storage? When you run the AppEngine development server locally, AppEngine emulates connecting to Google Cloud Storage, but it does not communicate with the real thing. You may be trying to access an object that exists in Google Cloud Storage but does not exist in the local, emulated environment.

Note that this is not the case for accessing Google Cloud Storage through the Google API Python Client (which you're not using), which is separate from App Engine and contacts the real Google Cloud Storage regardless of which App Engine environment it runs in.