I'm trying to create a bucket with versioning enabled.
I've followed Google Cloud documentation here, with the addition of creating the bucket, my code looks like the following:
public class LocalEmulatorStorageClientProvider : IStorageClientProvider
{
public const string BucketName = "test-bucket";
public async Task<StorageClient> CreateStorageClient()
{
var storageClient = await new StorageClientBuilder
{
BaseUri = "http://localhost:8083/storage/v1/",
UnauthenticatedAccess = true,
}.BuildAsync();
if (!BucketExists(storageClient, BucketName))
{
await storageClient.CreateBucketAsync("test-project", BucketName);
var bucket = await storageClient.GetBucketAsync(BucketName);
bucket.Versioning = new Bucket.VersioningData
{
Enabled = true
};
await storageClient.UpdateBucketAsync(bucket);
}
return storageClient;
}
private bool BucketExists(StorageClient storageClient, string bucketName)
{
try
{
storageClient.GetBucket(bucketName);
return true;
}
catch (Exception ex)
{
return false;
}
}
}
I'm running into a problem where the client throws when calling UpdateBucketAsync() with the following exception: The service storage has thrown an exception. HttpStatusCode is NotFound. Not Found which corresponds to the fake-gcs-server container logs:
It looks like your failing request is a PUT request to update a bucket. I'm no GoLang expert, but it seems that the code doesn't support PUT requests on that route:
I'm trying to create a bucket with versioning enabled.
I've followed Google Cloud documentation here, with the addition of creating the bucket, my code looks like the following:
I'm running into a problem where the client throws when calling
UpdateBucketAsync()
with the following exception:The service storage has thrown an exception. HttpStatusCode is NotFound. Not Found
which corresponds to thefake-gcs-server
container logs:Theres nothing I can spot in the docs that suggest I'm missing something here.