Generate S3 object pre-signed URL in one command
Go Makefile
Latest commit 0ebc096 Feb 6, 2017 @dtan4 committed on GitHub Merge pull request #15 from dtan4/v1.0.0-release-date
Update v1.0.0 release date


Build Status codecov GitHub release

Generate S3 object pre-signed URL in one command

$ s3url s3://my-bucket/foo.key***************************%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20160923T010227Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=****************************************************************



Using Homebrew (OS X only)

Formula is available at dtan4/homebrew-tools.

$ brew tap dtan4/tools
$ brew install s3url

Precompiled binary

Precompiled binaries for Windows, OS X, Linux are available at Releases.

From source

$ go get -d
$ cd $GOPATH/src/
$ make deps
$ make install


You need to set AWS credentials beforehand, or you can also use named profile written in ~/.aws/credentials and ~/.aws/config.

export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
export AWS_REGION=xx-yyyy-0

Just type the command below and get Pre-signed URL on the screen.

# https:// URL (both virtual-hosted-style and path-style)
$ s3url [-d DURATION] [--profile PROFILE] [--upload UPLOAD]
$ s3url [-d DURATION] [--profile PROFILE] [--upload UPLOAD]

# s3:// URL
$ s3url s3://BUCKET/KEY [-d DURATION] [--profile PROFILE] [--upload UPLOAD]

# Using options
$ s3url -b BUCKET -k KEY [-d DURATION] [--profile PROFILE] [--upload UPLOAD]

Upload file together

If target object does not exist in the bucket yet, you can upload file with --upload flag before getting Pre-signed URL. Following example shows that uploading foo.key to s3://my-bucket/foo.key and getting Pre-signed URL of s3://my-bucket/foo.key will be executed in series.

$ s3url s3://my-bucket/foo.key --upload foo.key
uploaded: /path/to/foo.key***************************%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20160923T010227Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=****************************************************************


Option Description Required Default
-b, -bucket=BUCKET Bucket name Required (if no URL is specified)
-k, -key=KEY Object key Required (if no URL is specified)
-d, -duration=DURATION Valid duration in minutes 5
--profile=PROFILE AWS profile name
--upload=UPLOAD File to upload
-h, -help Print command line usage
-v, -version Print version


Retrieve this repository and build using make.

$ go get -d
$ cd $GOPATH/src/
$ make deps
$ make


MIT License