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

Method marshalJSON

post-policy.go:419–438  ·  view source on GitHub ↗

marshalJSON - Provides Marshaled JSON in bytes.

()

Source from the content-addressed store, hash-verified

417
418// marshalJSON - Provides Marshaled JSON in bytes.
419func (p PostPolicy) marshalJSON() []byte {
420 expirationStr := `"expiration":"` + p.expiration.UTC().Format(expirationDateFormat) + `"`
421 var conditionsStr string
422 conditions := []string{}
423 for _, po := range p.conditions {
424 conditions = append(conditions, fmt.Sprintf("[\"%s\",\"%s\",\"%s\"]", po.matchType, po.condition, po.value))
425 }
426 if p.contentLengthRange.min != 0 || p.contentLengthRange.max != 0 {
427 conditions = append(conditions, fmt.Sprintf("[\"content-length-range\", %d, %d]",
428 p.contentLengthRange.min, p.contentLengthRange.max))
429 }
430 if len(conditions) > 0 {
431 conditionsStr = `"conditions":[` + strings.Join(conditions, ",") + "]"
432 }
433 retStr := "{"
434 retStr = retStr + expirationStr + ","
435 retStr += conditionsStr
436 retStr += "}"
437 return []byte(retStr)
438}
439
440// base64 - Produces base64 of PostPolicy's Marshaled json.
441func (p PostPolicy) base64() string {

Callers 2

StringMethod · 0.95
base64Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected