示例#1
0
 public async Task<ObjectListing> ListObjects(string bucketName, string prefix)
 {
     ListObjectsRequest temp = new ListObjectsRequest(bucketName)
     {
         Prefix = prefix
     };
     return await  this.ListObjects(temp);
 }
示例#2
0
        public async Task<ObjectListing> ListObjects(ListObjectsRequest listObjectsRequest)
        {
            ObjectListing result = null;
            OssHttpRequestMessage httpRequestMessage = null;
            HttpResponseMessage response = null;
            try
            {
                Dictionary<string, string> parameters = new Dictionary<string, string>();
                if (listObjectsRequest.Prefix != null)
                {
                    parameters.Add("prefix", listObjectsRequest.Prefix);

                }
                if (listObjectsRequest.Delimiter != null)
                {
                    parameters.Add("delimiter", listObjectsRequest.Delimiter);

                }
                if (listObjectsRequest.Marker != null)
                {
                    parameters.Add("marker", listObjectsRequest.Marker);

                }
                if (listObjectsRequest.MaxKeys != null)
                {
                    parameters.Add("maxKeys", listObjectsRequest.MaxKeys.ToString());

                }

                httpRequestMessage = new OssHttpRequestMessage(listObjectsRequest.BucketName, null, parameters);

                httpRequestMessage.Method = HttpMethod.Get;
                httpRequestMessage.Headers.Date = DateTime.UtcNow;

                OssRequestSigner.Sign(httpRequestMessage, networkCredential);
                response = await httpClient.SendAsync(httpRequestMessage);

                if (response.IsSuccessStatusCode == false)
                {
                    await ErrorResponseHandler.Handle(response);
                }

                var temp = DeserializerFactory.GetFactory().CreateListObjectsResultDeserializer();
                result = await temp.Deserialize(response);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (httpRequestMessage != null)
                    httpRequestMessage.Dispose();

                if (response != null)
                    response.Dispose();
            }
            return result;
        }
示例#3
0
        static async void listObjects()
        {
            try
            {
                OssClient temp = new OssClient("bm9crcnr0rtnuw8bnrfvq7w8", "RbtJoExTnA8vYLynUfDh7Ior+oM=");
                ListObjectsRequest arg = new ListObjectsRequest("devdoc2");
               arg.Delimiter=@"/";
               // arg.Prefix = @".NET Reflector 7.0.0.420 Crack/"
                ObjectListing result = await temp.ListObjects(arg );

            }
            catch (AggregateException ex)
            {
                Console.WriteLine(ex.Message);

            }
        }