MCPcopy
hub / github.com/minio/minio-go / ParseBucketCorsConfig

Function ParseBucketCorsConfig

pkg/cors/cors.go:61–79  ·  view source on GitHub ↗

ParseBucketCorsConfig parses a CORS configuration in XML from an io.Reader.

(reader io.Reader)

Source from the content-addressed store, hash-verified

59
60// ParseBucketCorsConfig parses a CORS configuration in XML from an io.Reader.
61func ParseBucketCorsConfig(reader io.Reader) (*Config, error) {
62 var c Config
63
64 // Max size of cors document is 64KiB according to https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketCors.html
65 // This limiter is just for safety so has a max of 128KiB
66 err := xml.NewDecoder(io.LimitReader(reader, 128*humanize.KiByte)).Decode(&c)
67 if err != nil {
68 return nil, fmt.Errorf("decoding xml: %w", err)
69 }
70 if c.XMLNS == "" {
71 c.XMLNS = defaultXMLNS
72 }
73 for i, rule := range c.CORSRules {
74 for j, method := range rule.AllowedMethod {
75 c.CORSRules[i].AllowedMethod[j] = strings.ToUpper(method)
76 }
77 }
78 return &c, nil
79}
80
81// ToXML marshals the CORS configuration to XML.
82func (c Config) ToXML() ([]byte, error) {

Callers 2

getBucketCorsMethod · 0.92
TestCORSXMLMarshalFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestCORSXMLMarshalFunction · 0.68