當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。