Viewing CORS Rules
If you have any questions during development, post them on the Issues page of GitHub. For details about parameters and usage of each API, see the API Reference
You can call ObsClient.GetBucketCors to view CORS rules of a bucket. Sample code is as follows:
// Create an instance of ObsClient.
ObsClient client = new ObsClient("*** Provide your Access Key ***", "*** Provide your Secret Key ***", "https://your-endpoint");
// View CORS rules.
try
{
GetBucketCorsConfigurationRequest request = new GetBucketCorsConfigurationRequest();
request.BucketName = "bucketname";
GetBucketCorsResponse response = client.GetBucketCors(request);
foreach (CorsRule rule in response.Configuration.Rules)
{
Console.WriteLine("rule id is: {0}\n", rule.Id);
foreach (string allowOrigin in rule.AllowedOrigins)
{
Console.WriteLine("allowOrigin is: {0}\n", allowOrigin);
}
foreach (string allowHeader in rule.AllowedHeaders)
{
Console.WriteLine("allowHeader is: {0}\n", allowHeader);
}
foreach (HttpVerb allowMethod in rule.AllowedMethods)
{
Console.WriteLine("allowMethod is: {0}\n", allowMethod);
}
foreach (string exposeHeader in rule.ExposeHeaders)
{
Console.WriteLine("exposeHeader is: {0}\n", exposeHeader);
}
Console.WriteLine("rule maxAgeSeconds is: {0}\n", rule.MaxAgeSeconds);
}
}
catch (ObsException ex)
{
Console.WriteLine("ErrorCode: {0}", ex.ErrorCode);
Console.WriteLine("ErrorMessage: {0}", ex.ErrorMessage);
}
Last Article: Setting CORS Rules
Next Article: Deleting CORS Rules
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.