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 range params in the policy #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
16 changes: 12 additions & 4 deletions obs/model_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,20 @@ type CreateSignedUrlOutput struct {
ActualSignedRequestHeaders http.Header
}

// ConditionRange the specifying ranges in the conditions
type ConditionRange struct {
RangeName string
Lower int64
Upper int64
}

// CreateBrowserBasedSignatureInput is the input parameter of CreateBrowserBasedSignature function.
type CreateBrowserBasedSignatureInput struct {
Bucket string
Key string
Expires int
FormParams map[string]string
Bucket string
Key string
Expires int
FormParams map[string]string
RangeParams []ConditionRange
}

// CreateBrowserBasedSignatureOutput is the result of CreateBrowserBasedSignature function.
Expand Down
4 changes: 4 additions & 0 deletions obs/temporary_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func (obsClient ObsClient) CreateBrowserBasedSignature(input *CreateBrowserBased
originPolicySlice = append(originPolicySlice, "[\"starts-with\", \"$key\", \"\"],")
}

for _, v := range input.RangeParams {
originPolicySlice = append(originPolicySlice, fmt.Sprintf("[\"%s\", %d, %d],", v.RangeName, v.Lower, v.Upper))
}

originPolicySlice = append(originPolicySlice, "]}")

originPolicy := strings.Join(originPolicySlice, "")
Expand Down