Skip to content

Commit

Permalink
Merge pull request #10 from rhnvrm/develop
Browse files Browse the repository at this point in the history
fix: missing optional fields in policy
  • Loading branch information
rhnvrm authored Jan 29, 2021
2 parents fbf23c1 + 01c1568 commit cacb5dc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (s3 *S3) CreateUploadPolicies(uploadConfig UploadConfig) (UploadPolicies, e
}

func buildUploadSign(nowTime time.Time, credential string, uploadConfig UploadConfig) ([]byte, error) {
// essential conditions
conditions := []interface{}{
map[string]string{"bucket": uploadConfig.BucketName},
map[string]string{"key": uploadConfig.ObjectKey},
Expand All @@ -126,6 +127,16 @@ func buildUploadSign(nowTime time.Time, credential string, uploadConfig UploadCo
map[string]string{"x-amz-algorithm": algorithm},
map[string]string{"x-amz-date": nowTime.Format(amzDateISO8601TimeFormat)},
}

// optional conditions
if uploadConfig.ContentDisposition != "" {
conditions = append(conditions, map[string]string{"Content-Disposition": uploadConfig.ContentDisposition})
}

if uploadConfig.ACL != "" {
conditions = append(conditions, map[string]string{"x-amz-acl": uploadConfig.ACL})
}

for k, v := range uploadConfig.MetaData {
conditions = append(conditions, map[string]string{k: v})
}
Expand Down

0 comments on commit cacb5dc

Please sign in to comment.