policy

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package policy provides post policy helpers for browser-based uploads.

Package policy provides S3 POST policy helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition added in v1.0.5

type Condition struct {
	MatchType string
	Condition string
	Value     string
}

Condition represents a single policy condition.

type ContentLengthRange added in v1.0.5

type ContentLengthRange struct {
	Min int64
	Max int64
}

ContentLengthRange represents the allowed content length range.

type PostPolicy added in v1.0.5

type PostPolicy struct {
	// contains filtered or unexported fields
}

PostPolicy describes the policy used for browser uploads.

func NewPostPolicy added in v1.0.5

func NewPostPolicy() *PostPolicy

NewPostPolicy creates a new PostPolicy instance.

func (*PostPolicy) AddCondition added in v1.0.5

func (p *PostPolicy) AddCondition(condition Condition) error

AddCondition adds a policy condition.

func (*PostPolicy) Base64 added in v1.0.5

func (p *PostPolicy) Base64() (string, error)

Base64 returns the Base64-encoded policy document.

func (*PostPolicy) Expiration added in v1.0.5

func (p *PostPolicy) Expiration() time.Time

Expiration returns the policy expiration time.

func (*PostPolicy) FormData added in v1.0.5

func (p *PostPolicy) FormData() map[string]string

FormData returns a copy of the form data map.

func (*PostPolicy) SetBucket added in v1.0.5

func (p *PostPolicy) SetBucket(bucketName string) error

SetBucket sets the target bucket condition.

func (*PostPolicy) SetCondition added in v1.0.5

func (p *PostPolicy) SetCondition(matchType, condition, value string) error

SetCondition sets a condition for x-amz-credential/date/algorithm.

func (*PostPolicy) SetContentDisposition added in v1.0.5

func (p *PostPolicy) SetContentDisposition(disposition string) error

SetContentDisposition sets the content-disposition condition.

func (*PostPolicy) SetContentEncoding added in v1.0.5

func (p *PostPolicy) SetContentEncoding(encoding string) error

SetContentEncoding sets the content-encoding condition.

func (*PostPolicy) SetContentLengthRange added in v1.0.5

func (p *PostPolicy) SetContentLengthRange(minLen, maxLen int64) error

SetContentLengthRange sets the allowed content length range.

func (*PostPolicy) SetContentType added in v1.0.5

func (p *PostPolicy) SetContentType(contentType string) error

SetContentType sets the content-type condition.

func (*PostPolicy) SetContentTypeStartsWith added in v1.0.5

func (p *PostPolicy) SetContentTypeStartsWith(prefix string) error

SetContentTypeStartsWith sets the content-type prefix condition.

func (*PostPolicy) SetEncryption added in v1.0.5

func (p *PostPolicy) SetEncryption(enc sse.Encrypter)

SetEncryption adds SSE headers to the form data.

func (*PostPolicy) SetExpires added in v1.0.5

func (p *PostPolicy) SetExpires(t time.Time) error

SetExpires sets the policy expiration time.

func (*PostPolicy) SetKey added in v1.0.5

func (p *PostPolicy) SetKey(key string) error

SetKey sets the exact object key condition.

func (*PostPolicy) SetKeyStartsWith added in v1.0.5

func (p *PostPolicy) SetKeyStartsWith(prefix string) error

SetKeyStartsWith sets the object key prefix condition.

func (*PostPolicy) SetSuccessActionRedirect added in v1.0.5

func (p *PostPolicy) SetSuccessActionRedirect(redirect string) error

SetSuccessActionRedirect sets the success redirect URL condition.

func (*PostPolicy) SetSuccessStatusAction added in v1.0.5

func (p *PostPolicy) SetSuccessStatusAction(status string) error

SetSuccessStatusAction sets the success status condition.

func (*PostPolicy) SetTagging added in v1.0.5

func (p *PostPolicy) SetTagging(taggingXML string) error

SetTagging sets the tagging condition for the post policy.

func (*PostPolicy) SetUserData added in v1.0.5

func (p *PostPolicy) SetUserData(key, value string) error

SetUserData sets custom x-amz- prefixed data condition.

func (*PostPolicy) SetUserMetadata added in v1.0.5

func (p *PostPolicy) SetUserMetadata(key, value string) error

SetUserMetadata sets user metadata condition.

func (*PostPolicy) SetUserMetadataStartsWith added in v1.0.5

func (p *PostPolicy) SetUserMetadataStartsWith(key, value string) error

SetUserMetadataStartsWith sets user metadata prefix condition.

func (*PostPolicy) String added in v1.0.5

func (p *PostPolicy) String() string

String returns the JSON policy as a string when available.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL