桶相关接口 返回结果 参数 类型 说明 Configuration CORSConfiguration 跨域访问规则,包含规则id,请求方法,请求源等信息 关于CORSConfiguration一些说明 参数 说明 AllowedMethods 允许的请求方法 AllowedOrigins 允许的请求源 AllowedHeaders 允许的请求头 ExposedHeaders 允许返回的Response Header MaxAgeSeconds 跨域请求结果的缓存时间 删除桶跨域访问配置 功能说明 跨域资源共享 (CORS) 定义了在一个域中加载的客户端 Web 应用程序与另一个域中的资源交互的方式。利用 CORS 支持,您可以构建丰富的客户端 Web 应用程序,同时可以选择性地允许跨源访问您的资源。 您可以通过DeleteCORSConfiguration接口删除桶跨域访问配置。 代码示例 plaintext using System; using System.Threading.Tasks; using Amazon.Runtime; using Amazon.S3; namespace DotNetSDK.BucketOperation { public class DeleteBucketCORSExample { public static async Task DeleteCORSConfiguration() { var accessKey " "; var secretKey " "; var endpoint " "; var bucketName " "; try { var credentials new BasicAWSCredentials(accessKey, secretKey); var conf new AmazonS3Config { ServiceURL endpoint }; var s3Client new AmazonS3Client(credentials, conf); var result await s3Client.DeleteCORSConfigurationAsync(bucketName); if (result.HttpStatusCode ! System.Net.HttpStatusCode.NoContent) { Console.WriteLine("fail to get bucket cors {0}, HttpStatusCode:{1}, ErrorCode:{2}.", bucketName, (int)result.HttpStatusCode, result.HttpStatusCode); } } catch (Exception e) { Console.WriteLine(e.Message); } } } }