Skip to content

Teamwork/s3pp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

s3pp

A package to help you create POST policies to upload files directly to Amazon S3, see the AWS docs for the all the available conditions and values.

Example

A working example is available in examples/form.go, below are the relevant parts:

form, err := s3pp.New(s3pp.Config{
        AWSCredentials: s3pp.AWSCredentials{
                AccessKeyID:     "key",
                SecretAccessKey: "secret",
        },
        Bucket:  "mybucket",
        Region:  "us-east-1",
        Expires: 10 * time.Minute,
        Key:     s3pp.Match("key", uuid.New()),
        Conditions: []s3pp.Condition{
                s3pp.Match("acl", "public-read"),
                s3pp.Match("success_action_status", "201"),
                s3pp.ContentLengthRange(1, 55000),
        },
})

form.Fields will contain all the fields generated from the conditions for the form and you can pass any additional conditions in Conditions. Available conditions are documented here: Creating a POST Policy.

The form:

<form action="{{.Action}}" method="POST" enctype="multipart/form-data">
  {{range $name, $value := .Fields}}
    <input type="text" name="{{$name}}" value="{{$value}}" readonly>
  {{end}}

  <input type="file" name="file">
  <input type="submit" value="Upload">
</form>

About

A package to help you create POST policies to upload files directly to Amazon S3

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages