-2

I'm trying to create folders in Google Cloud bucket using C#. So far, I've successfully created a bucket but I can't find material for creating folders on the internet. Can somebody help me?

Deniss T.
  • 2,526
  • 9
  • 21
riki
  • 187
  • 1
  • 17

1 Answers1

2

Let me rephrase and explain better.

Buckets do not have folders. The concept of the folder is implemented in the Cloud Storage to organize your data, but on the logical layer the bucket doesn't have them.

Let's use gsutil as an example:

If you run: gsutil cp your-file gs://your-bucket/abc/

gsutil will create the object gs://your-bucket/abc/your-file so the object name is ¨abc/your-file¨

Now let's see in C#:

private void CreateBucket(string bucketName)
{
    var storage = StorageClient.Create();
    storage.CreateBucket(s_projectId, bucketName);
    Console.WriteLine($"Created {bucketName}.");
}

If where bucketName you pass gs://your-bucket/abc

Your item will be placed in that route.

Stefan G.
  • 890
  • 5
  • 10