Todos os produtos
Search
Central de documentação

Object Storage Service:Delete object tags (C# SDK V1)

Última atualização: Sep 22, 2026

O recurso de tags de objeto permite marcar objetos usando pares chave-valor. Este tópico descreve como excluir tags de objeto.

Observações

  • Este tópico usa o endpoint público da região China (Hangzhou). Para acessar o OSS a partir de outros serviços do Alibaba Cloud na mesma região do OSS, use um endpoint interno. Para mais informações sobre as regiões e endpoints do OSS, consulte Regiões e endpoints.

  • Este tópico demonstra como criar uma instância OSSClient com um endpoint do OSS. Para configurações alternativas, como usar um domínio personalizado ou autenticar com credenciais do Security Token Service (STS), consulte Inicialização (C# SDK V1).

  • Para excluir as tags de um objeto, é necessário ter a permissão oss:DeleteObjectTagging. Para saber mais, consulte Conceder uma política personalizada.

Código de exemplo

O código de exemplo a seguir mostra como excluir tags de objeto:

using Aliyun.OSS;
using Aliyun.OSS.Common;

// Set yourEndpoint to the endpoint of the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com.
var endpoint = "yourEndpoint";
// Obtain access credentials from environment variables. Before running this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set.
var accessKeyId = Environment.GetEnvironmentVariable("OSS_ACCESS_KEY_ID");
var accessKeySecret = Environment.GetEnvironmentVariable("OSS_ACCESS_KEY_SECRET");
// Specify the bucket name. For example, examplebucket.
var bucketName = "examplebucket";
// Specify the full path of the object. The full path cannot contain the bucket name. For example, exampledir/exampleobject.txt.
var objectName = "exampledir/exampleobject.txt";
// Specify the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set the region to cn-hangzhou.
const string region = "cn-hangzhou";

// Create a ClientConfiguration instance and modify the default parameters as needed.
var conf = new ClientConfiguration();

// Set the signature version to V4.
conf.SignatureVersion = SignatureVersion.V4;

// Create an OssClient instance.
var client = new OssClient(endpoint, accessKeyId, accessKeySecret, conf);
client.SetRegion(region);
try
{
    // Delete the object tags.
    client.DeleteObjectTagging(bucketName,objectName);
    Console.WriteLine("Delete object tagging succeeded.");
}
catch (Exception ex)
{
    Console.WriteLine("Delete object tagging failed. {0}", ex.Message);
}

Referências

Para mais detalhes sobre a operação da API DeleteObjectTagging, consulte DeleteObjectTagging.