Re: [gs-discussion] create folder/directory through rest api

92 views
Skip to first unread message

Erevald Kullolli

unread,
Nov 9, 2012, 12:42:26 PM11/9/12
to gs-dis...@googlegroups.com
Here are some samples
https://developers.google.com/storage/docs/json_api/v1/libraries?hl=en


On Fri, Nov 9, 2012 at 6:58 PM, mokiSam <sam....@mokinetworks.com> wrote:
if you go to the content management tool at https://storage.cloud.google.com/, you can create buckets and folders. we are building our own GCS content manager on top of the rest api. how do I create a folder without uploading a file, just like in google's tool? thanks for your help.

--
 
 

Brian Dorsey

unread,
Nov 9, 2012, 6:00:24 PM11/9/12
to gs-dis...@googlegroups.com
The apis-explorer is a good way to experiment with the JSON API. Here is a link to storage.buckets.insert:



--
 
 

Jeffrey Silverman

unread,
Nov 9, 2012, 7:21:21 PM11/9/12
to gs-dis...@googlegroups.com
Sam

I've been doing some testing with the 

gsutil -D mb gs://BUCKETNAME

command.  I assume you are looking for the appropriate HTTP command to use to create a bucket without populating it, and I assume that once you know what the HTTP is, then you can write the code yourself.  Let me know if my assumptions are invalid.

The command that I used that worked for me was:

PUT /xyzzy-wq78/ HTTP/1.1\r\nHost: commondatastorage.googleapis.com\r\nAccept-Encoding: identity\r\nContent-Length: 0\r\nx-goog-api-version: 2\r\nx-goog-project-id: google.com:jeffsilverman\r\nAuthorization: Bearer ya29.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\nUser-Agent: Boto/2.5.2 (linux2) gsutil/3.18 (linux2)\r\n\r\n
 

This creates a bucket called xyzzy-wq78.  The Authorization field is sensitive, so if you have problems, be sure to scrub that field before you send it out for somebody to look at.

The response that I got was:

reply: 'HTTP/1.1 200 OK\r\n'
...

Of course, the important thing is that first line, the reply status code of 200.

Let me know that this answers your question.


Jeff Silverman
Google Developer Support Specialist.
Reply all
Reply to author
Forward
0 new messages