Project

s3_sign

0.0
No release in over 3 years
Low commit activity in last 3 years
A quick a dirty way to s3 sign string s3 urls using the aws-sdk
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
~> 10.0
~> 3.2.0

Runtime

~> 1.36
 Project Readme

S3Sign

S3Sign allows easy signing of already formatted s3 urls.

Installation

Add this line to your application's Gemfile:

gem 's3_sign'

And then execute:

$ bundle

Or install it yourself as:

$ gem install s3_sign

Usage

Initialize the bucket_name for for S3Sign. In rails for instance, you might add an initializer for this.

Setup

S3Sign.bucket_name = "super_s3_bucket"

The gem assumes you already have AWS (via aws-sdk) configured globally, something like this:

Aws.config.update({
  credentials: Aws::Credentials.new(AppConfig.aws.access_key, AppConfig.aws.secret_key)
})

API

The S3Sign module itself provides .url:

# Pass a full s3 url and 1 hour expiration
S3Sign.url "http://s3.amazonaws.com/bucket/foo.png", expires: 3600
# => "https://bucket.s3.amazonaws.com/foo.png?AWSAccessKeyId=access_key_id&Expires=1427243780&Signature=a3RzDgElxDpSZLgxurZLiw1a6Ny%3D"

# Pass a 'key' portion found under the bucket with default expiration
S3Sign.url "images/foo.png"

The gem also provides a S3Sign::Helper module, useful to mixin to rails controllers. It will add two helper methods to your controllers and views.

s3_signed_url_for_key - Takes a key/url and options

stable_s3_signed_url - Takes a url and options. Used for generating signatures that expire in the far future year 2036.

Contributing

  1. Fork it ( https://github.com/Kajabi/s3_sign/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request