当前位置: 首页>>代码示例>>C#>>正文


C# ListObjectsRequest.WithBucketName方法代码示例

本文整理汇总了C#中Amazon.S3.Model.ListObjectsRequest.WithBucketName方法的典型用法代码示例。如果您正苦于以下问题:C# ListObjectsRequest.WithBucketName方法的具体用法?C# ListObjectsRequest.WithBucketName怎么用?C# ListObjectsRequest.WithBucketName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Amazon.S3.Model.ListObjectsRequest的用法示例。


在下文中一共展示了ListObjectsRequest.WithBucketName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeleteFolder

        /// <summary>
        /// Delete a folder
        /// </summary>
        /// <param name="prefix">prefix</param>
        public void DeleteFolder(string prefix)
        {
            // Get all object with specified prefix
            var listRequest = new ListObjectsRequest();
            listRequest.WithBucketName(_bucketName).WithPrefix(prefix);

            var deleteRequest = new DeleteObjectsRequest();
            deleteRequest.BucketName = _bucketName;

            do
            {
                ListObjectsResponse listResponse = _client.ListObjects(listRequest);

                // Add all object with specified prefix to delete request.
                foreach (S3Object entry in listResponse.S3Objects)
                {
                    deleteRequest.AddKey(entry.Key);
                }

                if (listResponse.IsTruncated)
                {
                    listRequest.Marker = listResponse.NextMarker;
                }
                else
                {
                    listRequest = null;
                }
            }
            while (listRequest != null);

            // Delete all the object with specified prefix.
            if (deleteRequest.Keys.Count > 0)
            {
                var deleteResponse = _client.DeleteObjects(deleteRequest);
                deleteResponse.Dispose();
            }
        }
开发者ID:orcareih,项目名称:AST-Amazon-S3,代码行数:41,代码来源:AmazonS3FileSystem.cs

示例2: deleteFile

        private void deleteFile(bool hasFile, string fileType, int id)
        {
            if (hasFile)
            {
                DeleteObjectRequest request = new DeleteObjectRequest();
                request.WithBucketName("intelrecruiter");

                ListObjectsRequest listObjReq = new ListObjectsRequest();
                listObjReq.WithBucketName("intelrecruiter")
                    .WithPrefix(fileType + "/" + id.ToString());
                using (client = Amazon.AWSClientFactory.CreateAmazonS3Client("AKIAJ47VSG7WMA62WLCA", "3tqlHujlftpk6j/z5OtDw2eg9N2FJtz1RwL8bEa3"))
                {
                    var results = client.ListObjects(listObjReq).S3Objects;
                    foreach (var obj in results)
                    {
                        request.Key = obj.Key;
                        client.DeleteObject(request);
                    }
                }
            }
        }
开发者ID:nnennaude,项目名称:recruiter-web,代码行数:21,代码来源:ResumesController.cs

示例3: ListObjectsInBucket

        //***
        public System.Tuple<bool, List<string>> ListObjectsInBucket(AmazonS3Client client, string bucketName)
        {
            try
            {

                ListObjectsRequest request = new ListObjectsRequest();
                request.WithBucketName(bucketName);


                ListObjectsResponse response = client.ListObjects(request);
  
                List<string> retList = new List<string>();
                foreach (S3Object s3Object in response.S3Objects)
                    retList.Add(s3Object.Key);

                return new System.Tuple<bool, List<string>>(false, retList);
            }
            catch (Exception e)
            {
                return new System.Tuple<bool, List<string>>(false, new List<string>() { e.ToString()});
            }

        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:24,代码来源:AmazonS3Helper.cs

示例4: ListObjects

        private static void ListObjects(AmazonS3 s3Client, string bucket)
        {
            var request = new ListObjectsRequest();
              request.WithBucketName(bucket)
             .WithPrefix("key")
             .WithMaxKeys(4);
              do
              {
            ListObjectsResponse response = s3Client.ListObjects(request);

            if (response.IsTruncated)
            {
              request.Marker = response.NextMarker;
            }
            else
            {
              request = null;
            }
              } while (request != null);
        }
开发者ID:nrazon,项目名称:S3Emulator,代码行数:20,代码来源:Program.cs


注:本文中的Amazon.S3.Model.ListObjectsRequest.WithBucketName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。