-1

I want to rename objects name from Google Cloud Bucket using C# code. How can I do that?

Miguel
  • 956
  • 6
  • 20
riki
  • 187
  • 1
  • 17

1 Answers1

2

GCP Support here!

You can actually rename an existing object using C#. As stated in the documentation to do it you can use this code:

private void MoveObject(string bucketName, string sourceObjectName,
    string destObjectName)
{
    var storage = StorageClient.Create();
    storage.CopyObject(bucketName, sourceObjectName, bucketName,
        destObjectName);
    storage.DeleteObject(bucketName, sourceObjectName);
    Console.WriteLine($"Moved {sourceObjectName} to {destObjectName}.");
}

You'll see that what this code does is first copying the object with the new name, and then delete the old named object.

Here you can find more information on how to use client libraries such as for C# and other environments.

Miguel
  • 956
  • 6
  • 20