ShivarajRH
ShivarajRH

Reputation: 940

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://store.lonel.com/F9BEA944A8543F.jpg';

 $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://store.lonel.com/MMMF9BEA944A8543F.jpg',$ctx_res))
{
  die('Could not rename.');
}else{
    echo 'Done renaming';
}

I have inserted object using Google Cloud Storage API request.

Output:

Warning: Unable to rename: gs://store.lonel.com/MMMF9BEA944A8543F.jpg. Cloud Storage Error: NOT FOUND in C:\Program Files\Google\google_appengine\php\sdk\google\appengine\ext\cloud_storage_streams\CloudStorageRenameClient.php on line 77

Upvotes: 0

Views: 908

Answers (1)

Brandon Yarbrough
Brandon Yarbrough

Reputation: 38389

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.

Upvotes: 2

Related Questions