carrierwave-aws 1.0.0 → 1.0.1
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/.env.sample +1 -1
- data/.travis.yml +14 -14
- data/CHANGELOG.md +6 -0
- data/README.md +34 -9
- data/carrierwave-aws.gemspec +2 -1
- data/lib/carrierwave/aws/version.rb +1 -1
- data/lib/carrierwave/storage/aws_file.rb +6 -17
- data/spec/features/copying_files_spec.rb +4 -0
- data/spec/features/deleting_files_spec.rb +14 -0
- data/spec/features/storing_files_spec.rb +2 -1
- metadata +21 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 875d0be2d2390acf2e6a8c01a0df45b726079fe6
|
4
|
+
data.tar.gz: 3ed7510ef62090d5ba7b1974d313df1e327571f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2de20c43f2f6498533debf5027e55059383aaa273e210fb1f555c58d905e7353e507bf674459617235e86e0391c52492f6d48a5d92b168e25220249ad3f56a
|
7
|
+
data.tar.gz: dab3d28107e951dbfa5ab61e705aa49cdb6105619925ffe27acfb8aa79bbce945399bd28674d601bc85af9ceeb16697f9d3ffb99ed166b30c1a8bee261337f7c
|
data/.env.sample
CHANGED
data/.travis.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
|
+
cache: bundler
|
3
4
|
rvm:
|
4
5
|
- 2.1.5
|
5
6
|
- 2.2.2
|
@@ -7,19 +8,18 @@ rvm:
|
|
7
8
|
matrix:
|
8
9
|
allow_failures:
|
9
10
|
- rvm: ruby-head
|
10
|
-
script: bundle exec rspec
|
11
11
|
env:
|
12
12
|
global:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
- secure: |-
|
14
|
+
A6i5I0Y+ifiJr2yotcjMBOZxRnhaPbuDTuMW3PMMUaqHsCc2A5Tqemenb7WG
|
15
|
+
awCHOE6i9fuO/qAOPR3iKVdkR7Qv//CDtFZ9pZ7uiqVxfz1kYbv4aoPm1IvJ
|
16
|
+
Kd6Nons/AjkD+yhobP8WgiIZI/QcSylDZYNCasTwQlfOCdYLnag=
|
17
|
+
- secure: |-
|
18
|
+
IE4oVY30L0OH10J/poiEZ1PyFZgPY7dH1FneJI5OeYJJ8GfEHoLuMJXgBmyX
|
19
|
+
mC2v2PGK0pQTKGKFVV1mLhKdCzeLRCSMFqNvVo6blSoMLZoM1kj3sbU0kiIW
|
20
|
+
qAgafLka3iyxQnPsvfmjLVei3h+HOUIUV6QmagjcMfZREHfTDZk=
|
21
|
+
- secure: |-
|
22
|
+
B75vnSCFTnQgCP4dmz78VN/WWj88Tpnh4cjUCU0cQjQ5M7oQ0KTbM0d7WDyf
|
23
|
+
rf0F+B9OihBtLNQWqjocRvNH0dU5OzBLCC9DVolUgNwOdNTHW2I7CwlxJ5t7
|
24
|
+
ljQTxzPP+tFASwzBHjywbo7n0EX3efT5UOZhbD9LZL93X4SOlyU=
|
25
|
+
- AWS_REGION=us-east-1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## Version 1.0.1 2016-05-13
|
2
|
+
|
3
|
+
* Fixed: The `copy_to` method of `AWS::File` now uses the same `aws_acl`
|
4
|
+
configuration used on original uploads so ACL on copied files matches original
|
5
|
+
files. [Olivier Lacan]
|
6
|
+
|
1
7
|
## Version 1.0.0 2015-09-18
|
2
8
|
|
3
9
|
* Added: ACL options are verified when they are set, and coerced into usable
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Carrierwave AWS Storage
|
2
2
|
|
3
|
-
[](https://travis-ci.org/sorentwo/carrierwave-aws)
|
4
|
+
[](https://codeclimate.com/github/sorentwo/carrierwave-aws)
|
5
|
+
[](http://badge.fury.io/rb/carrierwave-aws)
|
6
|
+
[](https://gemnasium.com/sorentwo/carrierwave-aws)
|
7
7
|
|
8
8
|
Use the officially supported AWS-SDK library for S3 storage rather than relying
|
9
9
|
on fog. There are several things going for it:
|
@@ -28,6 +28,11 @@ Add this line to your application's Gemfile:
|
|
28
28
|
gem 'carrierwave-aws'
|
29
29
|
```
|
30
30
|
|
31
|
+
Run the bundle command from your shell to install it:
|
32
|
+
```bash
|
33
|
+
bundle install
|
34
|
+
```
|
35
|
+
|
31
36
|
## Usage
|
32
37
|
|
33
38
|
Configure and use it just like you would Fog. The only notable difference is
|
@@ -59,8 +64,7 @@ CarrierWave.configure do |config|
|
|
59
64
|
region: ENV.fetch('AWS_REGION') # Required
|
60
65
|
}
|
61
66
|
|
62
|
-
# Optional: Signing of download urls, e.g. for serving private
|
63
|
-
# content through CloudFront.
|
67
|
+
# Optional: Signing of download urls, e.g. for serving private content through CloudFront.
|
64
68
|
config.aws_signer = -> (unsigned_url, options) { Aws::CF::Signer.sign_url unsigned_url, options }
|
65
69
|
end
|
66
70
|
```
|
@@ -72,11 +76,11 @@ If you have a custom uploader that specifies additional headers for each URL, pl
|
|
72
76
|
```ruby
|
73
77
|
class MyUploader < Carrierwave::Uploader::Base
|
74
78
|
# Storage configuration within the uploader supercedes the global CarrierWave
|
75
|
-
# config, so
|
79
|
+
# config, so either comment out `storage :file`, or remove that line, otherwise
|
76
80
|
# AWS will not be used.
|
77
81
|
storage :aws
|
78
82
|
|
79
|
-
# You can find full list of custom headers in AWS SDK documentation on
|
83
|
+
# You can find a full list of custom headers in AWS SDK documentation on
|
80
84
|
# AWS::S3::S3Object
|
81
85
|
def download_url(filename)
|
82
86
|
url(response_content_disposition: %Q{attachment; filename="#{filename}"})
|
@@ -84,8 +88,29 @@ class MyUploader < Carrierwave::Uploader::Base
|
|
84
88
|
end
|
85
89
|
```
|
86
90
|
|
87
|
-
|
91
|
+
|
92
|
+
## Migrating From Fog
|
93
|
+
|
94
|
+
If you migrate from `fog` your uploader may be configured as `storage :fog`, simply comment out that line, as in the following example, or remove that specific line.
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
class MyUploader < Carrierwave::Uploader::Base
|
98
|
+
# Storage configuration within the uploader supercedes the global CarrierWave
|
99
|
+
# config, so adjust accordingly...
|
100
|
+
|
101
|
+
# Choose what kind of storage to use for this uploader:
|
102
|
+
# storage :file
|
103
|
+
# storage :fog
|
104
|
+
storage :aws
|
105
|
+
|
106
|
+
|
107
|
+
# More comments below in your file....
|
108
|
+
end
|
109
|
+
```
|
110
|
+
|
111
|
+
Another item particular to fog, you may have `url(query: {'my-header': 'my-value'})`.
|
88
112
|
With `carrierwave-aws` the `query` part becomes obsolete, just use a hash of headers.
|
113
|
+
If you skipped the section regarding Usage, you'll want to be sure everything is configured as it's explained in that section as well.
|
89
114
|
|
90
115
|
## Contributing
|
91
116
|
|
data/carrierwave-aws.gemspec
CHANGED
@@ -19,5 +19,6 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_dependency 'carrierwave', '~> 0.7'
|
20
20
|
gem.add_dependency 'aws-sdk', '~> 2.0'
|
21
21
|
|
22
|
-
gem.add_development_dependency '
|
22
|
+
gem.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
gem.add_development_dependency 'rspec', '~> 3.0'
|
23
24
|
end
|
@@ -4,6 +4,8 @@ module CarrierWave
|
|
4
4
|
attr_writer :file
|
5
5
|
attr_accessor :uploader, :connection, :path, :aws_options
|
6
6
|
|
7
|
+
delegate :content_type, :delete, :exists?, :size, to: :file
|
8
|
+
|
7
9
|
def initialize(uploader, connection, path)
|
8
10
|
@uploader = uploader
|
9
11
|
@connection = connection
|
@@ -21,18 +23,6 @@ module CarrierWave
|
|
21
23
|
file.data.to_h
|
22
24
|
end
|
23
25
|
|
24
|
-
def content_type
|
25
|
-
file.content_type
|
26
|
-
end
|
27
|
-
|
28
|
-
def delete
|
29
|
-
file.delete
|
30
|
-
end
|
31
|
-
|
32
|
-
def exists?
|
33
|
-
file.exists?
|
34
|
-
end
|
35
|
-
|
36
26
|
def extension
|
37
27
|
elements = path.split('.')
|
38
28
|
elements.last if elements.size > 1
|
@@ -48,16 +38,15 @@ module CarrierWave
|
|
48
38
|
file.get(aws_options.read_options).body.read
|
49
39
|
end
|
50
40
|
|
51
|
-
def size
|
52
|
-
file.content_length
|
53
|
-
end
|
54
|
-
|
55
41
|
def store(new_file)
|
56
42
|
!!file.put(aws_options.write_options(new_file))
|
57
43
|
end
|
58
44
|
|
59
45
|
def copy_to(new_path)
|
60
|
-
bucket.object(new_path).copy_from(
|
46
|
+
bucket.object(new_path).copy_from(
|
47
|
+
copy_source: "#{bucket.name}/#{file.key}",
|
48
|
+
acl: uploader.aws_acl
|
49
|
+
)
|
61
50
|
end
|
62
51
|
|
63
52
|
def signed_url(options = {})
|
@@ -19,7 +19,11 @@ describe 'Copying Files', type: :feature do
|
|
19
19
|
copy_attributes = copy.file.attributes
|
20
20
|
copy_attributes.reject! { |k,v| k == :last_modified }
|
21
21
|
|
22
|
+
copy_acl_grants = copy.file.file.acl.grants
|
23
|
+
original_acl_grants = original.file.file.acl.grants
|
24
|
+
|
22
25
|
expect(copy_attributes).to eq(original_attributes)
|
26
|
+
expect(copy_acl_grants).to eq(original_acl_grants)
|
23
27
|
|
24
28
|
image.close
|
25
29
|
original.file.delete
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Deleting Files', type: :feature do
|
4
|
+
let(:image) { File.open('spec/fixtures/image.png', 'r') }
|
5
|
+
let(:instance) { FeatureUploader.new }
|
6
|
+
|
7
|
+
before do
|
8
|
+
instance.aws_acl = 'public-read'
|
9
|
+
instance.store!(image)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'deletes the image when assigned a `nil` value' do
|
13
|
+
end
|
14
|
+
end
|
@@ -57,7 +57,8 @@ describe 'Storing Files', type: :feature do
|
|
57
57
|
instance.store!(image)
|
58
58
|
instance.retrieve_from_store!('image.png')
|
59
59
|
|
60
|
-
expect(instance.url).to
|
60
|
+
expect(instance.url).to include(ENV['S3_BUCKET_NAME'])
|
61
|
+
expect(instance.url).to include(instance.path)
|
61
62
|
|
62
63
|
image.close
|
63
64
|
instance.file.delete
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
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: 2016-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
@@ -38,20 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3'
|
61
|
+
version: '3.0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3'
|
68
|
+
version: '3.0'
|
55
69
|
description: Use aws-sdk for S3 support in CarrierWave
|
56
70
|
email:
|
57
71
|
- parker@sorentwo.com
|
@@ -81,6 +95,7 @@ files:
|
|
81
95
|
- spec/carrierwave/storage/aws_spec.rb
|
82
96
|
- spec/carrierwave/support/uri_filename_spec.rb
|
83
97
|
- spec/features/copying_files_spec.rb
|
98
|
+
- spec/features/deleting_files_spec.rb
|
84
99
|
- spec/features/storing_files_spec.rb
|
85
100
|
- spec/fixtures/image.png
|
86
101
|
- spec/spec_helper.rb
|
@@ -103,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
118
|
version: '0'
|
104
119
|
requirements: []
|
105
120
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.5.1
|
107
122
|
signing_key:
|
108
123
|
specification_version: 4
|
109
124
|
summary: A slimmer alternative to using Fog for S3 support in CarrierWave
|
@@ -114,6 +129,7 @@ test_files:
|
|
114
129
|
- spec/carrierwave/storage/aws_spec.rb
|
115
130
|
- spec/carrierwave/support/uri_filename_spec.rb
|
116
131
|
- spec/features/copying_files_spec.rb
|
132
|
+
- spec/features/deleting_files_spec.rb
|
117
133
|
- spec/features/storing_files_spec.rb
|
118
134
|
- spec/fixtures/image.png
|
119
135
|
- spec/spec_helper.rb
|