From 66ba593a19a7a9d1c302ff2b5c05bf17d73a0d1f Mon Sep 17 00:00:00 2001 From: lianggx6 <32149068+lianggx6@users.noreply.github.com> Date: Wed, 3 Jul 2024 23:14:19 +0800 Subject: [PATCH] feat: add SetContentDisposition method for postPolicy Upload (#1982) --- post-policy.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/post-policy.go b/post-policy.go index f6dbbf7f6..3f023704a 100644 --- a/post-policy.go +++ b/post-policy.go @@ -209,6 +209,23 @@ func (p *PostPolicy) SetContentTypeStartsWith(contentTypeStartsWith string) erro return nil } +// SetContentDisposition - Sets content-disposition of the object for this policy +func (p *PostPolicy) SetContentDisposition(contentDisposition string) error { + if strings.TrimSpace(contentDisposition) == "" || contentDisposition == "" { + return errInvalidArgument("No content disposition specified.") + } + policyCond := policyCondition{ + matchType: "eq", + condition: "$Content-Disposition", + value: contentDisposition, + } + if err := p.addNewPolicy(policyCond); err != nil { + return err + } + p.formData["Content-Disposition"] = contentDisposition + return nil +} + // SetContentLengthRange - Set new min and max content length // condition for all incoming uploads. func (p *PostPolicy) SetContentLengthRange(min, max int64) error {