carrierwave-aws 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/HISTORY.md +6 -0
- data/carrierwave-aws.gemspec +3 -3
- data/lib/carrierwave-aws.rb +2 -0
- data/lib/carrierwave/aws/version.rb +1 -1
- data/lib/carrierwave/storage/aws.rb +17 -9
- data/spec/carrierwave/storage/aws_spec.rb +41 -2
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a27752d4e7581b2b8d8f9a71b23c0c671c5a85e
|
4
|
+
data.tar.gz: 1e96f03161449d7d14f7d3272afb3a272ed8612b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d4dd67d51ef4a163107144b48336ffa0921facd5b969748d8d3d66fe7a15405b924c8b6b51624c6d22e53344b34e645bf2d9087d56a5621162b33a602f07a95
|
7
|
+
data.tar.gz: b73a9988c9b4f4b57ba4dc2e43bbc423b3e0a938caee3083e1d1d2a2771ba669fffcd5871f3939c1fe1ee6047b830517f3410afb48468b709a1e9264a4c3d093
|
data/.travis.yml
CHANGED
data/HISTORY.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## Version 0.4.0 2013-03-20
|
2
|
+
|
3
|
+
* Allow custom options for authenticated urls [Filipe Giusti]
|
4
|
+
* Loosen aws-sdk constraints
|
5
|
+
* Add `aws_read_options` and `aws_write_options` [Erik Hanson and Greg Woodward]
|
6
|
+
|
1
7
|
## Version 0.3.2 2013-08-06
|
2
8
|
|
3
9
|
* And we're back to passing the path. An updated integration test confirms it
|
data/carrierwave-aws.gemspec
CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.test_files = gem.files.grep(%r{^(spec)/})
|
17
17
|
gem.require_paths = ['lib']
|
18
18
|
|
19
|
-
gem.add_dependency 'carrierwave', '>= 0.7
|
20
|
-
gem.add_dependency 'aws-sdk', '>= 1.
|
19
|
+
gem.add_dependency 'carrierwave', '>= 0.7'
|
20
|
+
gem.add_dependency 'aws-sdk', '>= 1.29'
|
21
21
|
|
22
|
-
gem.add_development_dependency 'rspec', '~> 2.14
|
22
|
+
gem.add_development_dependency 'rspec', '~> 2.14'
|
23
23
|
end
|
data/lib/carrierwave-aws.rb
CHANGED
@@ -8,6 +8,8 @@ class CarrierWave::Uploader::Base
|
|
8
8
|
add_config :aws_credentials
|
9
9
|
add_config :aws_bucket
|
10
10
|
add_config :aws_acl
|
11
|
+
add_config :aws_read_options
|
12
|
+
add_config :aws_write_options
|
11
13
|
|
12
14
|
configure do |config|
|
13
15
|
config.storage_engines[:aws] = 'CarrierWave::Storage::AWS'
|
@@ -65,7 +65,7 @@ module CarrierWave
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def read
|
68
|
-
file.read
|
68
|
+
file.read(uploader_read_options)
|
69
69
|
end
|
70
70
|
|
71
71
|
def size
|
@@ -73,11 +73,7 @@ module CarrierWave
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def store(new_file)
|
76
|
-
@file = bucket.objects[path].write(
|
77
|
-
acl: uploader.aws_acl,
|
78
|
-
content_type: new_file.content_type,
|
79
|
-
file: new_file.path
|
80
|
-
}.merge(uploader.aws_attributes || {}))
|
76
|
+
@file = bucket.objects[path].write(uploader_write_options(new_file))
|
81
77
|
|
82
78
|
true
|
83
79
|
end
|
@@ -88,14 +84,14 @@ module CarrierWave
|
|
88
84
|
|
89
85
|
def url(options = {})
|
90
86
|
if uploader.aws_acl != :public_read
|
91
|
-
authenticated_url
|
87
|
+
authenticated_url(options)
|
92
88
|
else
|
93
89
|
public_url
|
94
90
|
end
|
95
91
|
end
|
96
92
|
|
97
|
-
def authenticated_url
|
98
|
-
file.url_for(:read, expires: uploader.aws_authenticated_url_expiration).to_s
|
93
|
+
def authenticated_url(options = {})
|
94
|
+
file.url_for(:read, { expires: uploader.aws_authenticated_url_expiration }.merge(options)).to_s
|
99
95
|
end
|
100
96
|
|
101
97
|
def public_url
|
@@ -106,6 +102,18 @@ module CarrierWave
|
|
106
102
|
end
|
107
103
|
end
|
108
104
|
|
105
|
+
def uploader_read_options
|
106
|
+
uploader.aws_read_options
|
107
|
+
end
|
108
|
+
|
109
|
+
def uploader_write_options(new_file)
|
110
|
+
{
|
111
|
+
acl: uploader.aws_acl,
|
112
|
+
content_type: new_file.content_type,
|
113
|
+
file: new_file.path
|
114
|
+
}.merge(uploader.aws_attributes || {}).merge(uploader.aws_write_options || {})
|
115
|
+
end
|
116
|
+
|
109
117
|
private
|
110
118
|
|
111
119
|
def bucket
|
@@ -31,8 +31,8 @@ describe CarrierWave::Storage::AWS::File do
|
|
31
31
|
let(:objects) { { 'files/1/file.txt' => file } }
|
32
32
|
let(:bucket) { double(:bucket, objects: objects) }
|
33
33
|
let(:connection) { double(:connection, buckets: { 'example-com' => bucket }) }
|
34
|
-
let(:file) { double(:file, read: '0101010') }
|
35
|
-
let(:uploader) { double(:uploader, aws_bucket: 'example-com', asset_host: nil) }
|
34
|
+
let(:file) { double(:file, read: '0101010', content_type: 'content/type', path: '/file/path') }
|
35
|
+
let(:uploader) { double(:uploader, aws_bucket: 'example-com', aws_acl: :public_read, aws_attributes: {}, asset_host: nil, aws_read_options: { encryption_key: 'abc' }, aws_write_options: { encryption_key: 'def' }) }
|
36
36
|
let(:path) { 'files/1/file.txt' }
|
37
37
|
|
38
38
|
subject(:aws_file) do
|
@@ -45,6 +45,37 @@ describe CarrierWave::Storage::AWS::File do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
describe '#uploader_write_options' do
|
49
|
+
it 'includes acl, content_type, file, aws_attributes, and aws_write_options' do
|
50
|
+
aws_file.uploader_write_options(file).should == {
|
51
|
+
acl: :public_read,
|
52
|
+
content_type: 'content/type',
|
53
|
+
file: '/file/path',
|
54
|
+
encryption_key: 'def'
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'works if aws_attributes is nil' do
|
59
|
+
uploader.stub(:aws_attributes) { nil }
|
60
|
+
expect {
|
61
|
+
aws_file.uploader_write_options(file)
|
62
|
+
}.to_not raise_error
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'works if aws_write_options is nil' do
|
66
|
+
uploader.stub(:aws_write_options) { nil }
|
67
|
+
expect {
|
68
|
+
aws_file.uploader_write_options(file)
|
69
|
+
}.to_not raise_error
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#uploader_read_options' do
|
74
|
+
it 'includes aws_read_options' do
|
75
|
+
aws_file.uploader_read_options.should == { encryption_key: 'abc' }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
48
79
|
describe '#to_file' do
|
49
80
|
it 'returns the internal file instance' do
|
50
81
|
aws_file.to_file.should be(file)
|
@@ -59,6 +90,14 @@ describe CarrierWave::Storage::AWS::File do
|
|
59
90
|
|
60
91
|
aws_file.authenticated_url
|
61
92
|
end
|
93
|
+
|
94
|
+
it 'requests a url for reading with custom options' do
|
95
|
+
uploader.stub(aws_authenticated_url_expiration: 60)
|
96
|
+
|
97
|
+
file.should_receive(:url_for).with(:read, hash_including(response_content_disposition: 'attachment'))
|
98
|
+
|
99
|
+
aws_file.authenticated_url(response_content_disposition: 'attachment')
|
100
|
+
end
|
62
101
|
end
|
63
102
|
|
64
103
|
describe '#url' do
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parker Selbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.7
|
19
|
+
version: '0.7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.7
|
26
|
+
version: '0.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: aws-sdk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: '1.29'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: '1.29'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.14
|
47
|
+
version: '2.14'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.14
|
54
|
+
version: '2.14'
|
55
55
|
description: Use aws-sdk for S3 support in CarrierWave
|
56
56
|
email:
|
57
57
|
- parker@sorentwo.com
|
@@ -59,10 +59,10 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- .env.sample
|
63
|
-
- .gitignore
|
64
|
-
- .rspec
|
65
|
-
- .travis.yml
|
62
|
+
- ".env.sample"
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
66
|
- Gemfile
|
67
67
|
- HISTORY.md
|
68
68
|
- LICENSE.txt
|
@@ -86,17 +86,17 @@ require_paths:
|
|
86
86
|
- lib
|
87
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.2.0
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: A slimmer alternative to using Fog for S3 support in CarrierWave
|