Skip to content

Instantly share code, notes, and snippets.

@ThomasAlxDmy
ThomasAlxDmy / gist:d60372970884ae797fdaed227a2dafee
Last active November 21, 2016 17:51
aws s3 S3AuthorizedUpload
// 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)