Todos os produtos
Search
Central de documentação

Object Storage Service:Consultar a capacidade de armazenamento de um bucket (C# SDK V2)

Última atualização: Sep 22, 2026

Este tópico descreve como consultar a capacidade de armazenamento de um bucket específico, incluindo o número de objetos e a capacidade de armazenamento de cada classe de armazenamento.

Observações

O código de exemplo neste tópico usa a região China (Hangzhou) (cn-hangzhou) como exemplo. Por padrão, o endpoint público é usado. Para acessar o OSS a partir de outros serviços Alibaba Cloud na mesma região, use o endpoint interno. Para mais informações sobre as regiões e endpoints compatíveis com o OSS, consulte Regions and endpoints.

Código de exemplo

Use o código a seguir para consultar a capacidade de armazenamento de um bucket.

using OSS = AlibabaCloud.OSS.V2; // Create an alias for Alibaba Cloud OSS SDK to simplify subsequent use.

var region = "cn-hangzhou"; // Required. Specify the region where the bucket is located. In this example, the China (Hangzhou) region is used. Set the region to cn-hangzhou.
var bucket = "your bucket name";  // Required. Specify the name of the destination bucket.  
var endpoint = null as string;  // Optional. Specify the endpoint used to access the OSS service. In this example, the China (Hangzhou) region is used. Set the endpoint to https://oss-cn-hangzhou.aliyuncs.com.

// Load the default configurations of the OSS SDK. The configurations automatically read credential information (such as AccessKey) from environment variables.
var cfg = OSS.Configuration.LoadDefault();
// Explicitly set to use environment variables to obtain credentials for identity verification (format: OSS_ACCESS_KEY_ID, OSS_ACCESS_KEY_SECRET).
cfg.CredentialsProvider = new OSS.Credentials.EnvironmentVariableCredentialsProvider();
// Set the region of the bucket in the configuration.
cfg.Region = region;
// If an endpoint is specified, overwrite the default endpoint.
if(endpoint != null)
{
    cfg.Endpoint = endpoint;
} 

// Create an OSS client instance using the configuration information.
using var client = new OSS.Client(cfg);

// Call the GetBucketStatAsync method to query the storage capacity information of the specified bucket.
var result = await client.GetBucketStatAsync(new OSS.Models.GetBucketStatRequest()
{
    Bucket = bucket
});

// Print the result information.
Console.WriteLine("GetBucketStat done");  // The operation is complete.
Console.WriteLine($"StatusCode: {result.StatusCode}");  // The HTTP status code.
Console.WriteLine($"RequestId: {result.RequestId}");  // The request ID, which is used by Alibaba Cloud to troubleshoot issues.
Console.WriteLine("Response Headers:");  // The response header information.
result.Headers.ToList().ForEach(x => Console.WriteLine(x.Key + " : " + x.Value));  // Traverse and print all response headers.
Console.WriteLine($"Storage: {result.BucketStat!.Storage}");  //  Print the total storage capacity of the bucket.
Console.WriteLine($"ObjectCount: {result.BucketStat!.ObjectCount}");  //  Print the total number of objects in the bucket.

Informações comuns de capacidade de armazenamento

Parâmetro

Descrição

Storage

Capacidade total de armazenamento do bucket. Unidade: bytes.

ObjectCount

Número total de objetos no bucket.

MultipartUploadCount

Número de tarefas de upload multipart iniciadas, mas ainda não concluídas nem canceladas no bucket.

LiveChannelCount

Número de LiveChannels no bucket.

LastModifiedTime

Momento em que as informações de armazenamento foram obtidas por esta chamada. O valor é um timestamp UNIX. Unidade: segundos.

StandardStorage

Capacidade de armazenamento dos objetos Standard. Unidade: bytes.

StandardObjectCount

Número de objetos Standard.

InfrequentAccessStorage

Capacidade de armazenamento faturável dos objetos Infrequent Access (IA). Unidade: bytes.

InfrequentAccessRealStorage

Capacidade real de armazenamento dos objetos IA. Unidade: bytes.

InfrequentAccessObjectCount

Número de objetos IA.

ArchiveStorage

Capacidade de armazenamento faturável dos objetos Archive Storage. Unidade: bytes.

ArchiveRealStorage

Capacidade real de armazenamento dos objetos Archive Storage. Unidade: bytes.

ArchiveObjectCount

Número de objetos Archive Storage.

ColdArchiveStorage

Capacidade de armazenamento faturável dos objetos Cold Archive. Unidade: bytes.

ColdArchiveRealStorage

Capacidade real de armazenamento dos objetos Cold Archive. Unidade: bytes.

ColdArchiveObjectCount

Número de objetos Cold Archive.

Referências

Para o código de exemplo completo, consulte GetBucketStat.cs.