Giter Site home page Giter Site logo

s3url's Introduction

s3url(1)

Build Status codecov GitHub release

Generate S3 object pre-signed URL in one command

$ s3url s3://my-bucket/foo.key
https://my-bucket.s3-ap-northeast-1.amazonaws.com/foo.key?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA***************************%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20160923T010227Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=****************************************************************

Contents

Installation

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 github.com/dtan4/s3url
$ cd $GOPATH/src/github.com/dtan4/s3url
$ make deps
$ make install

Usage

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

export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXXXX
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 https://BUCKET.s3-region.amazonaws.com/KEY [-d DURATION] [--profile PROFILE] [--upload UPLOAD]
$ s3url https://s3-region.amazonaws.com/BUCKET/KEY [-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
https://my-bucket.s3-ap-northeast-1.amazonaws.com/foo.key?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA***************************%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20160923T010227Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=****************************************************************

Options

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

Development

Retrieve this repository and build using make.

$ go get -d github.com/dtan4/s3url
$ cd $GOPATH/src/github.com/dtan4/s3url
$ make deps
$ make

License

MIT License

s3url's People

Contributors

dtan4 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.