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


C# AmazonS3.ListBuckets方法代码示例

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


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

示例1: ClassInitialize

        public static void ClassInitialize(TestContext context)
        {
            try
            {
                client = ClientTests.CreateClient();

                var buckets = client.ListBuckets();
                bucket = buckets.Buckets.First();
            }
            catch (Exception e)
            {
                Assert.Inconclusive("prerequisite: unable to create client or bucket.  Error: {0}", e.Message);
            }
        }
开发者ID:pbutlerm,项目名称:dataservices-sdk-dotnet,代码行数:14,代码来源:UpdateObjectTests.cs

示例2: CheckForBucket

 public static void CheckForBucket(string itemKey, AmazonS3 s3Client)
 {
     if (HttpContext.Current.User.Identity.IsAuthenticated)
     {
         string userBucketName = String.Format(Settings.Default.BucketNameFormat, HttpContext.Current.User.Identity.Name, itemKey);
         using (ListBucketsResponse listBucketsResponse = s3Client.ListBuckets())
         {
             S3Bucket bucket = listBucketsResponse.Buckets.FirstOrDefault(b => b.BucketName == userBucketName);
             if (bucket == null)
             {
                 PutBucketRequest putBucketRequest = new PutBucketRequest()
                     .WithBucketName(userBucketName);
                 PutBucketResponse putBucketResponse = s3Client.PutBucket(putBucketRequest);
                 putBucketResponse.Dispose();
             }
         }
     }
 }
开发者ID:bernardoleary,项目名称:MyBigBro,代码行数:18,代码来源:BucketHelper.cs

示例3: Initialize_S3_stuff

        public static bool Initialize_S3_stuff()
        {
            Console.WriteLine("starting Initialize_S3_stuff()");

            s3_client = null;
            bucketName = null;
            try
            {
                if (!Utils.CFG.ContainsKey("s3_bucketName"))
                {
                    Console.WriteLine("param s3_bucketName is not found in ez3d.config");
                    return false;
                }
                s3_client = AWSClientFactory.CreateAmazonS3Client();

            //                ListBucketsRequest listBucketsRequest = new ListBucketsRequest();
                ListBucketsResponse response = s3_client.ListBuckets();

                foreach (S3Bucket bucket in response.Buckets)
                {
                    if (bucket.BucketName == (String)Utils.CFG["s3_bucketName"])
                    {
                        bucketName = bucket.BucketName;
                        Console.WriteLine("bucketName =" + bucketName);
                    }
                }

                if (bucketName == null)
                {
                    Console.WriteLine("(bucketName == null)");
                    return false;
                }

                Console.WriteLine("Initialize_S3_stuff fininshed succefully");
                return true;
            }
            catch (AmazonS3Exception e)
            {
                Console.WriteLine("AmazonS3Exception caught !!!");
                Console.WriteLine(e.Message);
                return false;
            }
        }
开发者ID:tamirez3dco,项目名称:Rendering_Code,代码行数:43,代码来源:S3.cs

示例4: GetBucket

 private S3Bucket GetBucket(AmazonS3 client)
 {
     ListBucketsRequest listRequest = new ListBucketsRequest();
     ListBucketsResponse response = client.ListBuckets(listRequest);
     return response.Buckets
         .Where(candidate => candidate.BucketName == this.BucketName)
         .FirstOrDefault();
 }
开发者ID:oo00spy00oo,项目名称:SharedTerminals,代码行数:8,代码来源:AmazonOptionPanel.cs

示例5: DoesBucketExist

 private bool DoesBucketExist(AmazonS3 client)
 {
     using (ListBucketsResponse listBucketsResponse = client.ListBuckets())
         return (listBucketsResponse.Buckets.Any(b => b.BucketName == BucketName));
 }
开发者ID:sonbua,项目名称:Mantle,代码行数:5,代码来源:AwsS3StorageClient.cs

示例6: CreateBucket

        private static void CreateBucket(AmazonS3 client, string bucketname)
        {
            Console.Out.WriteLine("Checking S3 bucket with name " + bucketname);

            ListBucketsResponse response = client.ListBuckets();

            bool found = false;
            foreach (S3Bucket bucket in response.Buckets)
            {
                if (bucket.BucketName == bucketname)
                {
                    Console.Out.WriteLine("   Bucket found will not create it.");
                    found = true;
                    break;
                }
            }

            if (found == false)
            {
                Console.Out.WriteLine("   Bucket not found will create it.");

                client.PutBucket(new PutBucketRequest().WithBucketName(bucketname));

                Console.Out.WriteLine("Created S3 bucket with name " + bucketname);
            }
        }
开发者ID:xescrp,项目名称:breinstormin,代码行数:26,代码来源:S3Engine.cs


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