View gist:d60372970884ae797fdaed227a2dafee
// Server
func S3signatureGeneration() string{
now := time.Now().UTC()
policyDate, dateStamp := now.Format(ISO8601BasicFormat), now.Format(ISO8601BasicFormatShort)
expirationTime := now.Add(uploadValidity + 5*time.Minute).Format(ISO8601)
allowedPath := "test/"
credential := XAMZCredential(awsAccessKeyID, dateStamp, awsRegion)
str := "{ \"expiration\": \"%s\",\"conditions\": [{\"bucket\": \"%s\"},[\"starts-with\", \"$key\", \"%s\"],{\"acl\": \"%s\"},{\"x-amz-credential\": \"%s\"},{\"x-amz-algorithm\": \"AWS4-HMAC-SHA256\"},{\"x-amz-date\": \"%s\" }]}"
finalStr := fmt.Sprintf(str, expirationTime, awsBucket, allowedPath, acl, credential, policyDate)