예제 #1
0
        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 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);
            }
        }