/// <summary> /// 获取桶存量信息 /// </summary> /// <param name="bucketName"></param> /// <returns></returns> public Task <BucketStorageInfo> GetBucketStorageInfoAsync(string bucketName) { GetBucketStorageInfoRequest request = new GetBucketStorageInfoRequest { BucketName = bucketName, }; GetBucketStorageInfoResponse response = _client.GetBucketStorageInfo(request); if (response == null || response.StatusCode != HttpStatusCode.OK) { throw new Exception($"Get bucket '{bucketName}' storage info failed."); } return(Task.FromResult(new BucketStorageInfo() { Size = response.Size, ObjectNumber = response.ObjectNumber, })); }
private static void GetBucketStorageInfo() { try { GetBucketStorageInfoRequest request = new GetBucketStorageInfoRequest() { BucketName = bucketName }; GetBucketStorageInfoResponse response = client.GetBucketStorageInfo(request); Console.WriteLine("GetBucketStorageInfo response response: " + response.StatusCode); Console.WriteLine("Object Number={0}", response.ObjectNumber); Console.WriteLine("Size={0}", response.Size); } catch (ObsException ex) { Console.WriteLine(string.Format("Exception errorcode: {0}, when get bucket storage info.", ex.ErrorCode)); Console.WriteLine("Exception errormessage: {0}", ex.ErrorMessage); } }
/// <summary> /// 获取桶的存量信息,包含桶的空间大小以及对象个数。 /// </summary> /// <param name="request">获取桶存量信息的请求参数。</param> /// <returns>获取桶存量信息的响应结果。</returns> public GetBucketStorageInfoResponse GetBucketStorageInfo(GetBucketStorageInfoRequest request) { return(DoRequest <GetBucketStorageInfoRequest, GetBucketStorageInfoResponse>(request)); }
/// <summary> /// Start the asynchronous request for obtaining the bucket storage information. /// </summary> /// <param name="request">Parameters in a request for obtaining the bucket storage information</param> /// <param name="callback">Asynchronous request callback function</param> /// <param name="state">Asynchronous request status object</param> /// <returns>Response to the asynchronous request</returns> public IAsyncResult BeginGetBucketStorageInfo(GetBucketStorageInfoRequest request, AsyncCallback callback, object state) { return(BeginDoRequest <GetBucketStorageInfoRequest>(request, callback, state)); }