README.md in cognac-0.1.0 vs README.md in cognac-0.1.1
- old
+ new
@@ -1,9 +1,13 @@
# 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.
+This is a lightweight gem for implementing Amazon S3 upload using CORS support. The dependencies are kept to a minimum for easier maintenance.
+This gem builds the AWS authentication signature as described in http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html. It requires the Amazon keys, as well as options about the request (request type, resource, etc).
+
+To experiment with this code, run `bin/console` for an interactive prompt.
+
## Installation
Add this line to your application's Gemfile:
```ruby
@@ -28,14 +32,16 @@
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])
+ file_name = Cognac::CloudFile.generate(params[:filename])
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}
+ url = Cognac::Signature.build_s3_upload_url(resource_end_point, ENV["AWS_ACCESS_KEY_ID"], ENV["AWS_SECRET_ACCESS_KEY"], options)
+
+ render :json => {:put_url => url, :file_url => resource_end_point}
end
```
## Development