Sha256: 8676e1ee6a5d4e1a4fc14ff083d59d5bc286222ad5b4a78a0848a4a676222b51

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

# Cognac

This is a lightweight gem for implementing Amazon S3 upload using CORS support. The dependencies are kept to a minimum for easier maintenance. To experiment with this code, run `bin/console` for an interactive prompt.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'cognac'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install cognac

## Versions

Ruby 2.2.2
ActiveSupport 4.2.3

## Usage

You can use this gem in your Rails controller like this:

```ruby
  def generate_signed_s3_url
    # To avoid file collision, we prepend string to the file_name
    file_name = Cognac::CloudFile.generate(params[:file_name])
    resource_end_point = Cognac::CloudFile.resource_end_point(ENV["AWS_S3_BUCKET"], file_name)
    options = Cognac::Signature.generate_options_for_build_s3_upload_url(ENV["AWS_S3_BUCKET"], file_name, params[:content_type])
    url = AwsHelper.build_s3_upload_url(resource_endpoint, ENV["AWS_ACCESS_KEY_ID"], ENV["AWS_SECRET_ACCESS_KEY"], options)
    render :json => {:put_url => url, :file_url => resource_endpoint}
  end
```

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Run the tests:

```sh
$ruby -rminitest/pride test/cognac_test.rb 
```

Bug reports and pull requests are welcome on Bitbucket at https://bitbucket.org/bparanj/cognac.

## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cognac-0.1.0 README.md