cognac 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/README.md +1 -1
- data/cognac.gemspec +1 -1
- data/lib/cognac/version.rb +1 -1
- data/lib/cognac.rb +13 -4
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d86971bb20a88cf6d836ee65efce4386553cf6c0
|
|
4
|
+
data.tar.gz: c41738a6e82b804746588401eb22afff221a8d86
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4640a5c398bd1f4f76b6ce9944aa67cf181e9c1d96b5b21432e3ec14df452fe7b7a2a7112e3ee31a63294f8c662ebdf1c94f13cf33e8076ce71639ae14494cc
|
|
7
|
+
data.tar.gz: 6d39d5d12e8a0f2fd48274fd7551307d84e3b9814290cd5867bd7997a9a0adb907069015ee791a3ac6a248961fbaf46ece7933142ce9095924b6264eb782cdf0
|
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cognac
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.2.2
|
data/README.md
CHANGED
data/cognac.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.email = ["bparanj@gmail.com"]
|
|
11
11
|
|
|
12
12
|
spec.summary = %q{A simple library to implement Amazon S3 upload using CORS.}
|
|
13
|
-
spec.description
|
|
13
|
+
spec.description = %q{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).}
|
|
14
14
|
spec.homepage = "http://www.rubyplus.com"
|
|
15
15
|
spec.license = "MIT"
|
|
16
16
|
|
data/lib/cognac/version.rb
CHANGED
data/lib/cognac.rb
CHANGED
|
@@ -41,10 +41,10 @@ module Cognac
|
|
|
41
41
|
Base64.encode64(OpenSSL::HMAC.digest("sha1", secret_access_key, s)).strip
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
def self.build_s3_upload_url(
|
|
45
|
-
signature =
|
|
46
|
-
expires = signature_options
|
|
47
|
-
"#{
|
|
44
|
+
def self.build_s3_upload_url(end_point, aws_access_key, secret_access_key, signature_options = {})
|
|
45
|
+
signature = encoded_signature(secret_access_key, signature_options)
|
|
46
|
+
expires = expiration(signature_options)
|
|
47
|
+
"#{end_point}?AWSAccessKeyId=#{aws_access_key}&Expires=#{expires}&Signature=#{signature}"
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def self.generate_options_for_build_s3_upload_url(bucket, file_name, content_type)
|
|
@@ -65,5 +65,14 @@ module Cognac
|
|
|
65
65
|
def self.an_hour_from_now
|
|
66
66
|
1.hours.from_now.rfc822
|
|
67
67
|
end
|
|
68
|
+
|
|
69
|
+
def self.encoded_signature(secret_access_key, signature_options)
|
|
70
|
+
ERB::Util.url_encode(build_s3_rest_signature(secret_access_key, signature_options))
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def self.expiration(signature_options)
|
|
74
|
+
signature_options[:date] || an_hour_from_now
|
|
75
|
+
end
|
|
76
|
+
|
|
68
77
|
end
|
|
69
78
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cognac
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bala Paranj
|
|
@@ -76,6 +76,8 @@ extensions: []
|
|
|
76
76
|
extra_rdoc_files: []
|
|
77
77
|
files:
|
|
78
78
|
- ".gitignore"
|
|
79
|
+
- ".ruby-gemset"
|
|
80
|
+
- ".ruby-version"
|
|
79
81
|
- ".travis.yml"
|
|
80
82
|
- Gemfile
|
|
81
83
|
- LICENSE.txt
|