在C#应用程序中创建默认Google Cloud Storage存储桶区域时进行更改

时间:2019-03-05 10:01:55

标签: c# google-cloud-platform google-cloud-storage bucket

我对在C#应用程序中以编程方式创建存储桶时更改Google Cloud Storage存储桶区域感兴趣。方法如下:

StorageClient storageClient = StorageClient.Create();        
storageClient.CreateBucket(projectId, bucketName);

但是似乎无法更改默认区域。这应该很简单,但是我找不到任何信息。

1 个答案:

答案 0 :(得分:1)

来自official Google Cloud Storage sample

    private void CreateRegionalBucket(string location, string bucketName)
    {
        var storage = StorageClient.Create();
        Bucket bucket = new Bucket { Location = location, Name = bucketName };
        storage.CreateBucket(s_projectId, bucket);
        Console.WriteLine($"Created {bucketName}.");
    }