Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support tags for postPolicy Upload #1967

Merged
merged 3 commits into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions post-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ package minio

import (
"encoding/base64"
"errors"
"fmt"
"net/http"
"strings"
"time"

"github.com/minio/minio-go/v7/pkg/encrypt"
"github.com/minio/minio-go/v7/pkg/tags"
)

// expirationDateFormat date format for expiration key in json policy.
Expand Down Expand Up @@ -152,6 +154,27 @@ func (p *PostPolicy) SetCondition(matchType, condition, value string) error {
return errInvalidArgument("Invalid condition in policy")
}

// SetTagging - Sets tagging for the object for this policy based upload.
func (p *PostPolicy) SetTagging(tagging string) error {
if strings.TrimSpace(tagging) == "" || tagging == "" {
jiuker marked this conversation as resolved.
Show resolved Hide resolved
return errInvalidArgument("No tagging specified.")
}
_, err := tags.ParseObjectXML(strings.NewReader(tagging))
if err != nil {
return errors.New("The XML you provided was not well-formed or did not validate against our published schema.") //nolint
}
policyCond := policyCondition{
matchType: "eq",
condition: "$tagging",
value: tagging,
}
if err := p.addNewPolicy(policyCond); err != nil {
return err
}
p.formData["tagging"] = tagging
return nil
}

// SetContentType - Sets content-type of the object for this policy
// based upload.
func (p *PostPolicy) SetContentType(contentType string) error {
Expand Down
Loading