コード例 #1
0
ファイル: KS3Sample.cs プロジェクト: elvismile/ks3sdk-csharp
        public static bool setBucketCors()
        {
            try
            {
                Console.WriteLine("--- setBucketCors: ---");
                Console.WriteLine("Bucket Name: " + bucketName);
                PutBucketCorsRequest putBucketCorsRequest = new PutBucketCorsRequest();
                putBucketCorsRequest.BucketName = bucketName;
                BucketCorsConfigurationResult bucketCorsConfiguration = new BucketCorsConfigurationResult();
                IList <CorsRule> corsRule = new List <CorsRule>();
                CorsRule         rule     = new CorsRule();
                rule.AllowedMethods.Add(HttpMethod.PUT);
                rule.AllowedHeaders.Add("*");
                rule.AllowedOrigins.Add("http://www.example.com");
                rule.AllowedOrigins.Add("http://www.example.a.com");
                rule.ExposedHeaders.Add("*");
                rule.MaxAgeSeconds = 200;
                corsRule.Add(rule);
                bucketCorsConfiguration.Rules = corsRule;
                putBucketCorsRequest.BucketCorsConfiguration = bucketCorsConfiguration;

                ks3Client.setBucketCors(putBucketCorsRequest);

                Console.WriteLine("Success.");
                Console.WriteLine("----------------------\n");
            }
            catch (System.Exception e)
            {
                Console.WriteLine("setBucketCors Fail! " + e.ToString());
                return(false);
            }
            return(true);
        }
コード例 #2
0
ファイル: UnitTestKs3.cs プロジェクト: jflzbest/C-
 public void TestGetBucketCorsConfig()
 {
     if (init())
     {
         BucketCorsConfigurationResult bucketcors = ks3Client.getBucketCors(bucketName);
         Assert.IsNotNull(bucketcors);
     }
 }
コード例 #3
0
ファイル: KS3Sample.cs プロジェクト: elvismile/ks3sdk-csharp
        private static bool getBucketCorsConfig()
        {
            try
            {
                Console.WriteLine("--- getBucketCorsConfig: ---");
                Console.WriteLine("Bucket Name: " + bucketName);

                BucketCorsConfigurationResult bucketcors = ks3Client.getBucketCors(bucketName);

                Console.WriteLine("Success.");
                Console.WriteLine("----------------------\n");
            }
            catch (System.Exception e)
            {
                Console.WriteLine("getBucketCorsConfig Fail! " + e.ToString());
                return(false);
            }
            return(true);
        }
コード例 #4
0
ファイル: UnitTestKs3.cs プロジェクト: jflzbest/C-
        public void TestSetBucketCors()
        {
            if (init())
            {
                PutBucketCorsRequest putBucketCorsRequest = new PutBucketCorsRequest();
                putBucketCorsRequest.BucketName = bucketName;
                BucketCorsConfigurationResult bucketCorsConfiguration = new BucketCorsConfigurationResult();
                IList <CorsRule> corsRule = new List <CorsRule>();
                CorsRule         rule     = new CorsRule();
                rule.AllowedMethods.Add(HttpMethod.PUT);
                rule.AllowedHeaders.Add("*");
                rule.AllowedOrigins.Add("http://www.example.com");
                rule.AllowedOrigins.Add("http://www.example.a.com");
                rule.ExposedHeaders.Add("*");
                rule.MaxAgeSeconds = 200;
                corsRule.Add(rule);
                bucketCorsConfiguration.Rules = corsRule;
                putBucketCorsRequest.BucketCorsConfiguration = bucketCorsConfiguration;

                ks3Client.setBucketCors(putBucketCorsRequest);
            }
        }
コード例 #5
0
 public PutBucketCorsRequest(String bucketName, BucketCorsConfigurationResult bucketCorsConfiguration)
 {
     this.bucketName = bucketName;
     this.bucketCorsConfiguration = bucketCorsConfiguration;
 }
コード例 #6
0
        public void TestSetBucketCors()
        {
            if (init())
            {
                PutBucketCorsRequest putBucketCorsRequest = new PutBucketCorsRequest();
                putBucketCorsRequest.BucketName = bucketName;
                BucketCorsConfigurationResult bucketCorsConfiguration = new BucketCorsConfigurationResult();
                IList<CorsRule> corsRule = new List<CorsRule>();
                CorsRule rule = new CorsRule();
                rule.AllowedMethods.Add(HttpMethod.PUT);
                rule.AllowedHeaders.Add("*");
                rule.AllowedOrigins.Add("http://www.example.com");
                rule.AllowedOrigins.Add("http://www.example.a.com");
                rule.ExposedHeaders.Add("*");
                rule.MaxAgeSeconds = 200;
                corsRule.Add(rule);
                bucketCorsConfiguration.Rules = corsRule;
                putBucketCorsRequest.BucketCorsConfiguration = bucketCorsConfiguration;

                ks3Client.setBucketCors(putBucketCorsRequest);
            }
        }