carrierwave-aws 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 875d0be2d2390acf2e6a8c01a0df45b726079fe6
4
- data.tar.gz: 3ed7510ef62090d5ba7b1974d313df1e327571f4
3
+ metadata.gz: 1ae750711da052d59eef528b9ae939763fcaf09d
4
+ data.tar.gz: cd0697fdf6214142081cb3e019880437742ed056
5
5
  SHA512:
6
- metadata.gz: aa2de20c43f2f6498533debf5027e55059383aaa273e210fb1f555c58d905e7353e507bf674459617235e86e0391c52492f6d48a5d92b168e25220249ad3f56a
7
- data.tar.gz: dab3d28107e951dbfa5ab61e705aa49cdb6105619925ffe27acfb8aa79bbce945399bd28674d601bc85af9ceeb16697f9d3ffb99ed166b30c1a8bee261337f7c
6
+ metadata.gz: de81a897ac5e7a64053dfdcce11053feeddad8026ff06ee6ecec5236fc7df17830aa6b27820193b7d5d217bf454ef87c4155ff7392014bd57a20925060b2bbd4
7
+ data.tar.gz: 2ccc6e881ce7cc47050005c9f84ccd5197d29aca4c036565be5c8f3f85cd30b2a2eb3c3030475125962bd639476339460b8c0c61ace9cfafa79b44f9cf949f72
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'carrierwave'
2
4
  require 'carrierwave/aws/version'
3
5
  require 'carrierwave/storage/aws'
@@ -5,72 +7,82 @@ require 'carrierwave/storage/aws_file'
5
7
  require 'carrierwave/storage/aws_options'
6
8
  require 'carrierwave/support/uri_filename'
7
9
 
8
- class CarrierWave::Uploader::Base
9
- ACCEPTED_ACL = %w[
10
- private
11
- public-read
12
- public-read-write
13
- authenticated-read
14
- bucket-owner-read
15
- bucket-owner-full-control
16
- ].freeze
17
-
18
- ConfigurationError = Class.new(StandardError)
19
-
20
- add_config :aws_attributes
21
- add_config :aws_authenticated_url_expiration
22
- add_config :aws_credentials
23
- add_config :aws_bucket
24
- add_config :aws_read_options
25
- add_config :aws_write_options
26
- add_config :aws_acl
27
- add_config :aws_signer
28
-
29
- configure do |config|
30
- config.storage_engines[:aws] = 'CarrierWave::Storage::AWS'
31
- end
10
+ module CarrierWave
11
+ module Uploader
12
+ class Base
13
+ ACCEPTED_ACL = %w[
14
+ private
15
+ public-read
16
+ public-read-write
17
+ authenticated-read
18
+ bucket-owner-read
19
+ bucket-owner-full-control
20
+ ].freeze
32
21
 
33
- def self.aws_acl=(acl)
34
- @aws_acl = normalized_acl(acl)
35
- end
22
+ ConfigurationError = Class.new(StandardError)
36
23
 
37
- def self.normalized_acl(acl)
38
- normalized = acl.to_s.downcase.sub('_', '-')
24
+ add_config :aws_attributes
25
+ add_config :aws_authenticated_url_expiration
26
+ add_config :aws_credentials
27
+ add_config :aws_bucket
28
+ add_config :aws_read_options
29
+ add_config :aws_write_options
30
+ add_config :aws_acl
31
+ add_config :aws_signer
39
32
 
40
- unless ACCEPTED_ACL.include?(normalized)
41
- raise ConfigurationError.new("Invalid ACL option: #{normalized}")
42
- end
33
+ configure do |config|
34
+ config.storage_engines[:aws] = 'CarrierWave::Storage::AWS'
35
+ end
43
36
 
44
- normalized
45
- end
37
+ def self.aws_acl=(acl)
38
+ @aws_acl = normalized_acl(acl)
39
+ end
46
40
 
47
- def self.aws_signer(value = nil)
48
- self.aws_signer = value if value
41
+ def self.normalized_acl(acl)
42
+ normalized = acl.to_s.downcase.sub('_', '-')
49
43
 
50
- if instance_variable_defined?('@aws_signer')
51
- @aws_signer
52
- elsif superclass.respond_to? :aws_signer
53
- superclass.aws_signer
54
- end
55
- end
44
+ unless ACCEPTED_ACL.include?(normalized)
45
+ raise ConfigurationError, "Invalid ACL option: #{normalized}"
46
+ end
56
47
 
57
- def self.aws_signer=(signer)
58
- @aws_signer = validated_signer(signer)
59
- end
48
+ normalized
49
+ end
60
50
 
61
- def self.validated_signer(signer)
62
- unless signer.nil? || signer.instance_of?(Proc) && signer.arity == 2
63
- raise ConfigurationError.new("Invalid signer option. Signer proc has to respond to '.call(unsigned_url, options)'")
64
- end
51
+ def self.aws_signer(value = nil)
52
+ self.aws_signer = value if value
65
53
 
66
- signer
67
- end
54
+ if instance_variable_defined?('@aws_signer')
55
+ @aws_signer
56
+ elsif superclass.respond_to? :aws_signer
57
+ superclass.aws_signer
58
+ end
59
+ end
68
60
 
69
- def aws_acl=(acl)
70
- @aws_acl = self.class.normalized_acl(acl)
71
- end
61
+ def self.aws_signer=(signer)
62
+ @aws_signer = validated_signer(signer)
63
+ end
64
+
65
+ def self.validated_signer(signer)
66
+ unless signer.nil? || signer.instance_of?(Proc) && signer.arity == 2
67
+ raise ConfigurationError,
68
+ 'Invalid signer option. Signer proc has to respond to' \
69
+ '`.call(unsigned_url, options)`'
70
+ end
72
71
 
73
- def aws_signer
74
- instance_variable_defined?('@aws_signer') ? @aws_signer : self.class.aws_signer
75
- end
72
+ signer
73
+ end
74
+
75
+ def aws_acl=(acl)
76
+ @aws_acl = self.class.normalized_acl(acl)
77
+ end
78
+
79
+ def aws_signer
80
+ if instance_variable_defined?('@aws_signer')
81
+ @aws_signer
82
+ else
83
+ self.class.aws_signer
84
+ end
85
+ end
86
+ end
87
+ end
76
88
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Carrierwave
2
4
  module AWS
3
- VERSION = '1.0.1'
5
+ VERSION = '1.0.2'
4
6
  end
5
7
  end
@@ -1,5 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'aws-sdk-resources'
2
4
 
5
+ Aws.eager_autoload!(services: ['S3'])
6
+
3
7
  module CarrierWave
4
8
  module Storage
5
9
  class AWS < Abstract
@@ -23,7 +27,9 @@ module CarrierWave
23
27
 
24
28
  def connection
25
29
  @connection ||= begin
26
- self.class.connection_cache[credentials] ||= ::Aws::S3::Resource.new(*credentials)
30
+ conn_cache = self.class.connection_cache
31
+
32
+ conn_cache[credentials] ||= ::Aws::S3::Resource.new(*credentials)
27
33
  end
28
34
  end
29
35
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CarrierWave
2
4
  module Storage
3
5
  class AWSFile
@@ -17,7 +19,7 @@ module CarrierWave
17
19
  @file ||= bucket.object(path)
18
20
  end
19
21
 
20
- alias_method :to_file, :file
22
+ alias to_file file
21
23
 
22
24
  def attributes
23
25
  file.data.to_h
@@ -29,9 +31,9 @@ module CarrierWave
29
31
  end
30
32
 
31
33
  def filename(options = {})
32
- if file_url = url(options)
33
- CarrierWave::Support::UriFilename.filename(file_url)
34
- end
34
+ file_url = url(options)
35
+
36
+ CarrierWave::Support::UriFilename.filename(file_url) if file_url
35
37
  end
36
38
 
37
39
  def read
@@ -39,7 +41,7 @@ module CarrierWave
39
41
  end
40
42
 
41
43
  def store(new_file)
42
- !!file.put(aws_options.write_options(new_file))
44
+ file.put(aws_options.write_options(new_file))
43
45
  end
44
46
 
45
47
  def copy_to(new_path)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CarrierWave
2
4
  module Storage
3
5
  class AWSOptions
@@ -12,9 +14,10 @@ module CarrierWave
12
14
  end
13
15
 
14
16
  def write_options(new_file)
15
- { acl: uploader.aws_acl,
16
- body: new_file.to_file,
17
- content_type: new_file.content_type,
17
+ {
18
+ acl: uploader.aws_acl,
19
+ body: new_file.to_file,
20
+ content_type: new_file.content_type
18
21
  }.merge(aws_attributes).merge(aws_write_options)
19
22
  end
20
23
 
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CarrierWave
2
4
  module Support
3
5
  module UriFilename
4
6
  def self.filename(url)
5
7
  path = url.split('?').first
6
8
 
7
- URI.decode(path).gsub(/.*\/(.*?$)/, '\1')
9
+ URI.decode(path).gsub(%r{.*/(.*?$)}, '\1')
8
10
  end
9
11
  end
10
12
  end
@@ -21,17 +21,17 @@ describe CarrierWave::Uploader::Base do
21
21
 
22
22
  describe '#aws_acl' do
23
23
  it 'allows known acess control values' do
24
- expect {
24
+ expect do
25
25
  uploader.aws_acl = 'private'
26
26
  uploader.aws_acl = 'public-read'
27
27
  uploader.aws_acl = 'authenticated-read'
28
- }.not_to raise_exception
28
+ end.not_to raise_exception
29
29
  end
30
30
 
31
31
  it 'does not allow unknown control values' do
32
- expect {
32
+ expect do
33
33
  uploader.aws_acl = 'everybody'
34
- }.to raise_exception(CarrierWave::Uploader::Base::ConfigurationError)
34
+ end.to raise_exception(CarrierWave::Uploader::Base::ConfigurationError)
35
35
  end
36
36
 
37
37
  it 'normalizes the set value' do
@@ -81,17 +81,18 @@ describe CarrierWave::Uploader::Base do
81
81
  end
82
82
 
83
83
  describe '#aws_signer' do
84
- let(:signer_proc) { -> (unsigned_url, options) { } }
85
- let(:other_signer) { -> (unsigned_url, options) { } }
84
+ let(:signer_proc) { -> (_unsigned, _options) {} }
85
+ let(:other_signer) { -> (_unsigned, _options) {} }
86
86
 
87
87
  it 'allows proper signer object' do
88
88
  expect { uploader.aws_signer = signer_proc }.not_to raise_exception
89
89
  end
90
90
 
91
91
  it 'does not allow signer with unknown api' do
92
- signer_proc = -> (unsigned_url) { }
92
+ signer_proc = -> (_unsigned) {}
93
93
 
94
- expect { uploader.aws_signer = signer_proc }.to raise_exception(CarrierWave::Uploader::Base::ConfigurationError)
94
+ expect { uploader.aws_signer = signer_proc }
95
+ .to raise_exception(CarrierWave::Uploader::Base::ConfigurationError)
95
96
  end
96
97
 
97
98
  it 'can be overridden on an instance level' do
@@ -2,20 +2,19 @@ require 'spec_helper'
2
2
 
3
3
  describe CarrierWave::Storage::AWSFile do
4
4
  let(:path) { 'files/1/file.txt' }
5
- let(:file) { double(:file, content_type: 'content/type', path: '/file/path') }
5
+ let(:file) { double(:file, content_type: 'octet', path: '/file') }
6
6
  let(:bucket) { double(:bucket, object: file) }
7
7
  let(:connection) { double(:connection, bucket: bucket) }
8
8
 
9
9
  let(:uploader) do
10
10
  double(:uploader,
11
- aws_bucket: 'example-com',
12
- aws_acl: :'public-read',
13
- aws_attributes: {},
14
- asset_host: nil,
15
- aws_signer: nil,
16
- aws_read_options: { encryption_key: 'abc' },
17
- aws_write_options: { encryption_key: 'def' }
18
- )
11
+ aws_bucket: 'example-com',
12
+ aws_acl: :'public-read',
13
+ aws_attributes: {},
14
+ asset_host: nil,
15
+ aws_signer: nil,
16
+ aws_read_options: { encryption_key: 'abc' },
17
+ aws_write_options: { encryption_key: 'def' })
19
18
  end
20
19
 
21
20
  subject(:aws_file) do
@@ -58,14 +57,17 @@ describe CarrierWave::Storage::AWSFile do
58
57
  allow(uploader).to receive(:aws_acl) { :private }
59
58
  allow(uploader).to receive(:aws_authenticated_url_expiration) { 60 }
60
59
 
61
- expect(file).to receive(:presigned_url).with(:get, { expires_in: 60 })
60
+ expect(file).to receive(:presigned_url).with(:get, expires_in: 60)
62
61
 
63
62
  aws_file.url
64
63
  end
65
64
 
66
65
  it 'requests an signed url if url signing is configured' do
67
66
  signature = 'Signature=QWERTZ&Key-Pair-Id=XYZ'
68
- cloudfront_signer = -> (unsigned_url, options) { [unsigned_url, signature].join('?') }
67
+
68
+ cloudfront_signer = lambda do |unsigned_url, _|
69
+ [unsigned_url, signature].join('?')
70
+ end
69
71
 
70
72
  allow(uploader).to receive(:aws_signer) { cloudfront_signer }
71
73
  expect(file).to receive(:public_url) { 'http://example.com' }
@@ -33,7 +33,7 @@ describe CarrierWave::Storage::AWSOptions do
33
33
  describe '#write_options' do
34
34
  let(:file) { CarrierWave::SanitizedFile.new('spec/fixtures/image.png') }
35
35
 
36
- it 'includes acl, content_type, body (file), aws_attributes, and aws_write_options' do
36
+ it 'includes all access and file options' do
37
37
  uploader.aws_write_options = { encryption_key: 'def' }
38
38
 
39
39
  write_options = options.write_options(file)
@@ -49,17 +49,13 @@ describe CarrierWave::Storage::AWSOptions do
49
49
  it 'works if aws_attributes is nil' do
50
50
  expect(uploader).to receive(:aws_attributes) { nil }
51
51
 
52
- expect {
53
- options.write_options(file)
54
- }.to_not raise_error
52
+ expect { options.write_options(file) }.to_not raise_error
55
53
  end
56
54
 
57
55
  it 'works if aws_write_options is nil' do
58
56
  expect(uploader).to receive(:aws_write_options) { nil }
59
57
 
60
- expect {
61
- options.write_options(file)
62
- }.to_not raise_error
58
+ expect { options.write_options(file) }.to_not raise_error
63
59
  end
64
60
  end
65
61
 
@@ -71,9 +67,7 @@ describe CarrierWave::Storage::AWSOptions do
71
67
  end
72
68
 
73
69
  it 'allows expiration to be overridden' do
74
- expect(options.expiration_options(expires_in: 10)).to eq(
75
- expires_in: 10
76
- )
70
+ expect(options.expiration_options(expires_in: 10)).to eq(expires_in: 10)
77
71
  end
78
72
  end
79
73
  end
@@ -1,8 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CarrierWave::Storage::AWS do
4
- let(:credentials) { { access_key_id: 'abc', secret_access_key: '123', region: 'us-east-1' } }
5
- let(:uploader) { double(:uploader, aws_credentials: credentials) }
4
+ let(:credentials) do
5
+ { access_key_id: 'abc', secret_access_key: '123', region: 'us-east-1' }
6
+ end
7
+
8
+ let(:uploader) { double(:uploader, aws_credentials: credentials) }
6
9
 
7
10
  subject(:storage) do
8
11
  CarrierWave::Storage::AWS.new(uploader)
@@ -6,8 +6,8 @@ describe CarrierWave::Support::UriFilename do
6
6
  describe '.filename' do
7
7
  it 'extracts a decoded filename from file uri' do
8
8
  samples = {
9
- 'http://example.com/file.txt' => 'file.txt',
10
- 'http://example.com/files/1/file%201.txt?foo=bar/baz.txt' => 'file 1.txt',
9
+ 'http://ex.com/file.txt' => 'file.txt',
10
+ 'http://ex.com/files/1/file%201.txt?foo=bar/baz.txt' => 'file 1.txt'
11
11
  }
12
12
 
13
13
  samples.each do |uri, name|
@@ -14,10 +14,10 @@ describe 'Copying Files', type: :feature do
14
14
  copy.retrieve_from_store!('image2.png')
15
15
 
16
16
  original_attributes = original.file.attributes
17
- original_attributes.reject! { |k,v| k == :last_modified }
17
+ original_attributes.reject! { |key, _| key == :last_modified }
18
18
 
19
19
  copy_attributes = copy.file.attributes
20
- copy_attributes.reject! { |k,v| k == :last_modified }
20
+ copy_attributes.reject! { |key, _| key == :last_modified }
21
21
 
22
22
  copy_acl_grants = copy.file.file.acl.grants
23
23
  original_acl_grants = original.file.file.acl.grants
@@ -30,4 +30,3 @@ describe 'Copying Files', type: :feature do
30
30
  copy.file.delete
31
31
  end
32
32
  end
33
-
@@ -2,7 +2,7 @@ require 'carrierwave'
2
2
  require 'carrierwave-aws'
3
3
 
4
4
  def source_environment_file!
5
- return unless File.exists?('.env')
5
+ return unless File.exist?('.env')
6
6
 
7
7
  File.readlines('.env').each do |line|
8
8
  key, value = line.split('=')
@@ -11,7 +11,9 @@ def source_environment_file!
11
11
  end
12
12
 
13
13
  FeatureUploader = Class.new(CarrierWave::Uploader::Base) do
14
- def filename; 'image.png'; end
14
+ def filename
15
+ 'image.png'
16
+ end
15
17
  end
16
18
 
17
19
  RSpec.configure do |config|
@@ -33,12 +35,12 @@ RSpec.configure do |config|
33
35
  Kernel.srand config.seed
34
36
 
35
37
  config.before(:all, type: :feature) do
36
- CarrierWave.configure do |config|
37
- config.storage = :aws
38
- config.aws_bucket = ENV['S3_BUCKET_NAME']
39
- config.aws_acl = :'public-read'
38
+ CarrierWave.configure do |cw_config|
39
+ cw_config.storage = :aws
40
+ cw_config.aws_bucket = ENV['S3_BUCKET_NAME']
41
+ cw_config.aws_acl = :'public-read'
40
42
 
41
- config.aws_credentials = {
43
+ cw_config.aws_credentials = {
42
44
  access_key_id: ENV['S3_ACCESS_KEY'],
43
45
  secret_access_key: ENV['S3_SECRET_ACCESS_KEY'],
44
46
  region: ENV['AWS_REGION']
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Selbert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-13 00:00:00.000000000 Z
11
+ date: 2016-09-26 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
19
  version: '0.7'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0.7'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: aws-sdk
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -73,16 +79,6 @@ executables: []
73
79
  extensions: []
74
80
  extra_rdoc_files: []
75
81
  files:
76
- - ".env.sample"
77
- - ".gitignore"
78
- - ".rspec"
79
- - ".travis.yml"
80
- - CHANGELOG.md
81
- - Gemfile
82
- - LICENSE.txt
83
- - README.md
84
- - Rakefile
85
- - carrierwave-aws.gemspec
86
82
  - lib/carrierwave-aws.rb
87
83
  - lib/carrierwave/aws/version.rb
88
84
  - lib/carrierwave/storage/aws.rb
@@ -121,7 +117,7 @@ rubyforge_project:
121
117
  rubygems_version: 2.5.1
122
118
  signing_key:
123
119
  specification_version: 4
124
- summary: A slimmer alternative to using Fog for S3 support in CarrierWave
120
+ summary: Native aws-sdk support for S3 in CarrierWave
125
121
  test_files:
126
122
  - spec/carrierwave-aws_spec.rb
127
123
  - spec/carrierwave/storage/aws_file_spec.rb
@@ -1,4 +0,0 @@
1
- S3_BUCKET_NAME=BUCKET_NAME
2
- S3_ACCESS_KEY=YOUR_KEY
3
- S3_SECRET_ACCESS_KEY=YOUR_KEY
4
- AWS_REGION=BUCKET_REGION
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- *.gem
2
- .bundle
3
- .config
4
- .env
5
- Gemfile.lock
6
- bin
7
- vendor
8
- uploads
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --format progress
3
- --require spec_helper
@@ -1,25 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.1.5
6
- - 2.2.2
7
- - ruby-head
8
- matrix:
9
- allow_failures:
10
- - rvm: ruby-head
11
- env:
12
- global:
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
@@ -1,86 +0,0 @@
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
-
7
- ## Version 1.0.0 2015-09-18
8
-
9
- * Added: ACL options are verified when they are set, and coerced into usable
10
- values when possible.
11
- * Added: Specify an `aws_signer` lambda for use signing authenticated content
12
- served through services like CloudFront.
13
-
14
- ## Version 1.0.0-rc.1 2015-07-02
15
-
16
- * Continues where 0.6.0 left off. This wraps AWS-SDK v2 and all of the breaking
17
- changes that contains. Please see the specific breaking change notes contained
18
- in `0.6.0` below.
19
-
20
- ## Version 0.7.0 2015-07-02
21
-
22
- * Revert to AWS-SDK v1. There are too many breaking changes between v1 and v2 to
23
- be wrapped in a minor version change. This effectively reverts all changes
24
- betwen `0.5.0` and `0.6.0`, restoring the old `0.5.0` behavior.
25
-
26
- ## Version 0.6.0 2015-06-26
27
-
28
- * Breaking Change: Updated to use AWS-SDK v2 [Mark Oleson]
29
- * You must specify a region in your `aws_credentials` configuration
30
- * You must use hyphens in ACLs instead of underscores (`:public_read` becomes
31
- `:'public-read'` or `'public-read'`)
32
- * Authenticated URL's are now longer than 255 characters. If you are caching
33
- url values you'll need to ensure columns allow 255+ characters.
34
- * Authenticated URL expiration has been limited to 7 days.
35
-
36
- ## Version 0.5.0 2015-01-31
37
-
38
- * Change: Nudge the expected AWS-SDK version.
39
- * Fix `exists?` method of AWS::File (previously it always returned true)
40
- [Felix Bünemann]
41
- * Fix `filename` method of AWS::File for private files and remove url encoding.
42
- [Felix Bünemann]
43
-
44
- ## Version 0.4.1 2014-03-28
45
-
46
- * Fix regression in `aws_read_options` defaulting to `nil` rather than an empty
47
- hash. [Johannes Würbach]
48
-
49
- ## Version 0.4.0 2014-03-20
50
-
51
- * Allow custom options for authenticated urls [Filipe Giusti]
52
- * Loosen aws-sdk constraints
53
- * Add `aws_read_options` and `aws_write_options` [Erik Hanson and Greg Woodward]
54
-
55
- ## Version 0.3.2 2013-08-06
56
-
57
- * And we're back to passing the path. An updated integration test confirms it
58
- is working properly.
59
-
60
- ## Version 0.3.1 2013-05-23
61
-
62
- * Use the "alternate" object writing syntax. The primary method (as documented)
63
- only uploads the path itself rather than the file.
64
-
65
- ## Version 0.3.0 2013-05-23
66
-
67
- * Pass the file path directly to aws-sdk to prevent upload timeouts stemming
68
- incorrect `content_length`.
69
-
70
- ## Version 0.2.1 2013-04-20
71
-
72
- * Provide a `to_file` method on AWS::File in an attempt to prevent errors when
73
- re-uploading a cached file.
74
-
75
- ## Version 0.2.0 2013-04-19
76
-
77
- * Update aws-sdk depdendency to 1.8.5
78
- * Clean up some internal storage object passing
79
-
80
- ## Version 0.1.1 2013-04-09
81
-
82
- * Fix storage bug when if `aws_attributes` is blank [#1]
83
-
84
- ## Version 0.1.0 2013-02-04
85
-
86
- * Initial release, experimental with light expectation based spec coverage.
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in carrierwave-aws-sdk.gemspec
4
- gemspec
@@ -1,22 +0,0 @@
1
- Copyright (c) 2013 Parker Selbert
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,129 +0,0 @@
1
- # Carrierwave AWS Storage
2
-
3
- [![Build Status](https://travis-ci.org/sorentwo/carrierwave-aws.svg?branch=master)](https://travis-ci.org/sorentwo/carrierwave-aws)
4
- [![Code Climate](https://codeclimate.com/github/sorentwo/carrierwave-aws.svg)](https://codeclimate.com/github/sorentwo/carrierwave-aws)
5
- [![Gem Version](https://badge.fury.io/rb/carrierwave-aws.svg)](http://badge.fury.io/rb/carrierwave-aws)
6
- [![Dependency Status](https://gemnasium.com/sorentwo/carrierwave-aws.svg)](https://gemnasium.com/sorentwo/carrierwave-aws)
7
-
8
- Use the officially supported AWS-SDK library for S3 storage rather than relying
9
- on fog. There are several things going for it:
10
-
11
- * Full featured, it supports more of the API than Fog
12
- * Significantly smaller footprint
13
- * Fewer dependencies
14
- * Clear documentation
15
-
16
- Here is a simple comparison table [07/17/2013]
17
-
18
- | Library | Disk Space | Lines of Code | Boot Time | Runtime Deps | Develop Deps |
19
- | ------- | ---------- | ------------- | --------- | ------------ | ------------ |
20
- | fog | 28.0M | 133469 | 0.693 | 9 | 11 |
21
- | aws-sdk | 5.4M | 90290 | 0.098 | 3 | 8 |
22
-
23
- ## Installation
24
-
25
- Add this line to your application's Gemfile:
26
-
27
- ```ruby
28
- gem 'carrierwave-aws'
29
- ```
30
-
31
- Run the bundle command from your shell to install it:
32
- ```bash
33
- bundle install
34
- ```
35
-
36
- ## Usage
37
-
38
- Configure and use it just like you would Fog. The only notable difference is
39
- the use of `aws_bucket` instead of `fog_directory`, and `aws_acl` instead of
40
- `fog_public`.
41
-
42
- ```ruby
43
- CarrierWave.configure do |config|
44
- config.storage = :aws
45
- config.aws_bucket = ENV.fetch('S3_BUCKET_NAME')
46
- config.aws_acl = 'public-read'
47
-
48
- # Optionally define an asset host for configurations that are fronted by a
49
- # content host, such as CloudFront.
50
- config.asset_host = 'http://example.com'
51
-
52
- # The maximum period for authenticated_urls is only 7 days.
53
- config.aws_authenticated_url_expiration = 60 * 60 * 24 * 7
54
-
55
- # Set custom options such as cache control to leverage browser caching
56
- config.aws_attributes = {
57
- expires: 1.week.from_now.httpdate,
58
- cache_control: 'max-age=604800'
59
- }
60
-
61
- config.aws_credentials = {
62
- access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
63
- secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
64
- region: ENV.fetch('AWS_REGION') # Required
65
- }
66
-
67
- # Optional: Signing of download urls, e.g. for serving private content through CloudFront.
68
- config.aws_signer = -> (unsigned_url, options) { Aws::CF::Signer.sign_url unsigned_url, options }
69
- end
70
- ```
71
-
72
- ### Custom options for AWS URLs
73
-
74
- If you have a custom uploader that specifies additional headers for each URL, please try the following example:
75
-
76
- ```ruby
77
- class MyUploader < Carrierwave::Uploader::Base
78
- # Storage configuration within the uploader supercedes the global CarrierWave
79
- # config, so either comment out `storage :file`, or remove that line, otherwise
80
- # AWS will not be used.
81
- storage :aws
82
-
83
- # You can find a full list of custom headers in AWS SDK documentation on
84
- # AWS::S3::S3Object
85
- def download_url(filename)
86
- url(response_content_disposition: %Q{attachment; filename="#{filename}"})
87
- end
88
- end
89
- ```
90
-
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'})`.
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.
114
-
115
- ## Contributing
116
-
117
- In order to run the integration specs you will need to configure some
118
- environment variables. A sample file is provided as `.env.sample`. Copy it over
119
- and plug in the appropriate values.
120
-
121
- ```bash
122
- cp .env.sample .env
123
- ```
124
-
125
- 1. Fork it
126
- 2. Create your feature branch (`git checkout -b my-new-feature`)
127
- 3. Commit your changes (`git commit -am 'Add some feature'`)
128
- 4. Push to the branch (`git push origin my-new-feature`)
129
- 5. Create new Pull Request
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require 'bundler'
2
- require 'bundler/gem_tasks'
3
-
4
- Bundler.setup
5
-
6
- require 'rspec/core/rake_task'
7
-
8
- RSpec::Core::RakeTask.new(:spec)
9
-
10
- task default: :spec
@@ -1,24 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'carrierwave/aws/version'
5
-
6
- Gem::Specification.new do |gem|
7
- gem.name = 'carrierwave-aws'
8
- gem.version = Carrierwave::AWS::VERSION
9
- gem.authors = ['Parker Selbert']
10
- gem.email = ['parker@sorentwo.com']
11
- gem.description = %q{Use aws-sdk for S3 support in CarrierWave}
12
- gem.summary = %q{A slimmer alternative to using Fog for S3 support in CarrierWave}
13
- gem.homepage = 'https://github.com/sorentwo/carrierwave-aws'
14
-
15
- gem.files = `git ls-files`.split($/)
16
- gem.test_files = gem.files.grep(%r{^(spec)/})
17
- gem.require_paths = ['lib']
18
-
19
- gem.add_dependency 'carrierwave', '~> 0.7'
20
- gem.add_dependency 'aws-sdk', '~> 2.0'
21
-
22
- gem.add_development_dependency 'rake', '~> 10.0'
23
- gem.add_development_dependency 'rspec', '~> 3.0'
24
- end