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); }
public void TestGetBucketCorsConfig() { if (init()) { BucketCorsConfigurationResult bucketcors = ks3Client.getBucketCors(bucketName); Assert.IsNotNull(bucketcors); } }
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); }
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); } }
public PutBucketCorsRequest(String bucketName, BucketCorsConfigurationResult bucketCorsConfiguration) { this.bucketName = bucketName; this.bucketCorsConfiguration = bucketCorsConfiguration; }
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); } }