s3url-presigner

module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2019 License: MIT

README

s3url-presigner

Go Report Card GolangCI Release GoDoc

S3 URL presigner generates pre-signed S3 urls for PUT and GET requests

To install to your $GOPATH/bin

go get github.com/benderillo/s3url-presigner/cmd/s3url-presigner

Usage
Usage:
  main [OPTIONS]

Application Options:
  -b, --bucket=          S3 bucket [env: S3_BUCKET]
  -p, --path=            S3 path [env: S3_PATH]
  -m, --method=[get|put] HTTP method that needs to be presigned (default: get)
  -e, --expiry=          Expiration time for the url in seconds (default: 7200)

Help Options:
  -h, --help             Show this help message
Example input
s3url-presigner --bucket my-example-bucket --path /test/path/file.txt --method put --expiry 3600
Example output
https://my-example-bucket.s3.us-east-1.amazonaws.com/test/path/file.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=XXXXXXXXXXXXX%2F20190523%2Fus-east-1%2Fs3%2Faws4_request\u0026X-Amz-Date=20190523T032122Z\u0026X-Amz-Expires=3600\u0026X-Amz-Security-Token=FjopijpoirjpeoirgjsofdighsdfoighdiohgXXXXXXXXXXXXxxxxxxxxxxx\u0026X-Amz-SignedHeaders=host\u0026X-Amz-Signature=iddqdiddqdgodshowmethemoneygodiddqdiddqd
How to include it in your project
import (
	"time"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"

	"github.com/benderillo/s3url-presigner/pkg/storage"

	"golang.org/x/xerrors"
)

func main() {
	awsSession := session.Must(NewSessionWithOptions(session.Options{
		SharedConfigState: session.SharedConfigEnable,
	}))

	s3 := storage.NewStorage(awsSession)

	presignedUrl, expTime, err := s3.GetPresignedURL("put", "s3://bucket/path", time.Hour)

}

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

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