s3post

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2022 License: MIT Imports: 6 Imported by: 0

README

Build Status GoDoc

Package s3post signs POST policy documents for browser-based file uploads to AWS S3. More details on browser-based file uploads can be found in the AWS docs.

Both s3post and policy packages use only stdlib deps, no aws sdk required.

Usage

To use this package, generate a POST policy document then pass that policy into the Sign method to receive a signature to be used in a POST form.

Details on Policy documents can be found in the AWS docs.

The policy package can be used to generate these documents if necessary.

p := s3post.New("us-east-1", secret)
encoded, signed := p.Sign(policyBytes)

See the examples folder for complete usage.

Signature details

The policy document is signed using this calculation:

Signature Calculation

Documentation

Overview

Package s3post provides a function to sign a S3 POST upload policy

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Post

type Post struct {
	// contains filtered or unexported fields
}

Post holds information necessary for signing POST policy documents.

func New

func New(region, secret string) *Post

New returns an instance of Post that uses the passed in region and secret. If either is empty, environment variables will be used.

func (*Post) Sign

func (s *Post) Sign(policy []byte) (string, string)

Sign takes a POST policy and outputs the signed version of the policy as well as a signature to include in the POST form.

Signature is created by the calculation process here: http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-authentication-HTTPPOST.html

Returns the base64-encoded policy and the hex-encoded and signed policy. If an error occurs two empty strings will be returned.

Directories

Path Synopsis
examples
Package policy provides functionlity to create a POST policy for uploading a file directly from a browser to S3.
Package policy provides functionlity to create a POST policy for uploading a file directly from a browser to S3.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL