I am very new to the google cloud storage.
I want to create folder in bucket using php coding. I have searched a quite few sites and on 1 i saw it was written:
"Creating a folder inside a bucket will create a placeholder object named after the directory, has no data content and the mimetype application/x-directory. Directory placeholder objects created in Google Storage Manager are not supported."
I could not understand what it is trying to say. How can i create folder please help me out. I tried using the following code:
$req = new Google_HttpRequest("http://commondatastorage.googleapis.com/bucket/myfoldertrial");
$req->setRequestHeaders(array(
'x-goog-project-id' => 21212,
'x-goog-acl' => 'public-read',
'Content-Type' => 'application/x-directory'
));
$req->setRequestMethod('PUT');
$req->setPostBody('myfoldertrial');
I am using the API from following link:
Please help me out creating folder using PHP.
You probably don’t actually need to create a folder.
Google Storage isn’t a tree structure like your operating system’s filesystem uses, all Objects are stored in buckets at the top level. However you can give an Object a name with slashes in it, so it will kind of look like it is in a folder –
Users/username/docs/2012/09/21/activity.csvis a perfectly good name for an Object and doesn’t need any supporting folders.Once you’ve got Objects with this sort of scheme in place, you can list them as if you were viewing the contents of a folder with the
delimiterandprefixparameters as per these docs.So if you only wanted to create
myfoldertrialso you could uploadexample.pnginto it, there’s no need to create the folder, you can just upload straight tomyfoldertrial/example.png.