carrierwave-aws 0.2.1 → 0.3.0
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 +3 -0
- data/.gitignore +2 -0
- data/.travis.yml +1 -0
- data/HISTORY.md +5 -0
- data/README.md +26 -0
- data/lib/carrierwave/aws/version.rb +1 -1
- data/lib/carrierwave/storage/aws.rb +5 -5
- data/spec/carrierwave/storage/aws_spec.rb +6 -2
- data/spec/features/storing_files_spec.rb +29 -0
- data/spec/fixtures/image.png +0 -0
- data/spec/spec_helper.rb +11 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec70707302830ad68344002780286686534f2cfe
|
4
|
+
data.tar.gz: 5f6a31d07df412d97e8af6c70a7dc4dd89cc8212
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ced29508da5597363c14709224b971e03b8c237a38f830dc2a7aeaaf34d0d1b7cea9489471ca5238dc8576883a8db4e7530fcab0c70d05c6558e8772ded2690
|
7
|
+
data.tar.gz: a528306304867a49a75c8052378e43438a5d84ff69485865adb7354ec6073d0e5c1006e4288bf111be31fa9cad006cce535ab2377bb315b691623939c112c362
|
data/.env.sample
ADDED
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Carrierwave AWS Storage
|
2
2
|
|
3
3
|
[](https://travis-ci.org/sorentwo/carrierwave-aws)
|
4
|
+
[](https://codeclimate.com/github/sorentwo/carrierwave-aws)
|
5
|
+
[](http://badge.fury.io/rb/carrierwave-aws)
|
4
6
|
|
5
7
|
Use the officially supported AWS-SDK library for S3 storage rather than relying
|
6
8
|
on fog. There are several things going for it:
|
@@ -45,8 +47,32 @@ CarrierWave.configure do |config|
|
|
45
47
|
end
|
46
48
|
```
|
47
49
|
|
50
|
+
If you want to supply your own AWS configuration, put it inside
|
51
|
+
`config.aws_credentials` like this:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
config.aws_credentials = {
|
55
|
+
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
56
|
+
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
|
57
|
+
config: AWS.config(my_aws_options)
|
58
|
+
}
|
59
|
+
```
|
60
|
+
|
61
|
+
`AWS.config` will return `AWS::Core::Configuration` object which is used
|
62
|
+
through `aws-sdk` gem. Browse [Amazon docs](http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/Core/Configuration.html)
|
63
|
+
for additional info. For example, if you want to turn off SSL for your asset
|
64
|
+
URLs, you could simply set `AWS.config(use_ssl: false)`.
|
65
|
+
|
48
66
|
## Contributing
|
49
67
|
|
68
|
+
In order to run the integration specs you will need to configure some
|
69
|
+
environment variables. A sample file is provided as `.env.sample`. Copy it over
|
70
|
+
and plug in the appropriate values.
|
71
|
+
|
72
|
+
```bash
|
73
|
+
cp .env.sample .env
|
74
|
+
```
|
75
|
+
|
50
76
|
1. Fork it
|
51
77
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
78
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
@@ -7,6 +7,10 @@ module CarrierWave
|
|
7
7
|
@connection_cache ||= {}
|
8
8
|
end
|
9
9
|
|
10
|
+
def self.clear_connection_cache!
|
11
|
+
@connection_cache = {}
|
12
|
+
end
|
13
|
+
|
10
14
|
def store!(file)
|
11
15
|
File.new(uploader, connection, uploader.store_path).tap do |aws_file|
|
12
16
|
aws_file.store(file)
|
@@ -69,15 +73,11 @@ module CarrierWave
|
|
69
73
|
end
|
70
74
|
|
71
75
|
def store(new_file)
|
72
|
-
|
73
|
-
|
74
|
-
@file = bucket.objects[path].write(aws_file, {
|
76
|
+
@file = bucket.objects[path].write(new_file.file, {
|
75
77
|
acl: uploader.aws_acl,
|
76
78
|
content_type: new_file.content_type
|
77
79
|
}.merge(uploader.aws_attributes || {}))
|
78
80
|
|
79
|
-
aws_file.close unless aws_file.closed?
|
80
|
-
|
81
81
|
true
|
82
82
|
end
|
83
83
|
|
@@ -5,7 +5,11 @@ describe CarrierWave::Storage::AWS do
|
|
5
5
|
let(:uploader) { mock(:uploader, aws_credentials: credentials) }
|
6
6
|
|
7
7
|
subject(:storage) do
|
8
|
-
|
8
|
+
CarrierWave::Storage::AWS.new(uploader)
|
9
|
+
end
|
10
|
+
|
11
|
+
before do
|
12
|
+
CarrierWave::Storage::AWS.clear_connection_cache!
|
9
13
|
end
|
10
14
|
|
11
15
|
describe '#connection' do
|
@@ -32,7 +36,7 @@ describe CarrierWave::Storage::AWS::File do
|
|
32
36
|
let(:path) { 'files/1/file.txt' }
|
33
37
|
|
34
38
|
subject(:aws_file) do
|
35
|
-
|
39
|
+
CarrierWave::Storage::AWS::File.new(uploader, connection, path)
|
36
40
|
end
|
37
41
|
|
38
42
|
describe '#read' do
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if ENV['S3_BUCKET_NAME']
|
4
|
+
describe 'Storing Files' do
|
5
|
+
before(:all) do
|
6
|
+
CarrierWave.configure do |config|
|
7
|
+
config.storage = :aws
|
8
|
+
config.aws_bucket = ENV['S3_BUCKET_NAME']
|
9
|
+
config.aws_acl = :public_read
|
10
|
+
|
11
|
+
config.aws_credentials = {
|
12
|
+
access_key_id: ENV['S3_ACCESS_KEY'],
|
13
|
+
secret_access_key: ENV['S3_SECRET_ACCESS_KEY']
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'uploads the file to the configured bucket' do
|
19
|
+
image = File.open('spec/fixtures/image.png', 'r')
|
20
|
+
uploader = Class.new(CarrierWave::Uploader::Base)
|
21
|
+
instance = uploader.new
|
22
|
+
|
23
|
+
expect {
|
24
|
+
instance.store!(image)
|
25
|
+
instance.retrieve_from_store!('image_file.png')
|
26
|
+
}.to_not raise_error
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
Binary file
|
data/spec/spec_helper.rb
CHANGED
@@ -2,9 +2,20 @@ require 'rspec'
|
|
2
2
|
require 'carrierwave'
|
3
3
|
require 'carrierwave-aws'
|
4
4
|
|
5
|
+
def source_environment_file!
|
6
|
+
return unless File.exists?('.env')
|
7
|
+
|
8
|
+
File.readlines('.env').each do |line|
|
9
|
+
values = line.split('=')
|
10
|
+
ENV[values.first] = values.last.chomp
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
5
14
|
RSpec.configure do |config|
|
6
15
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
7
16
|
config.filter_run :focus
|
8
17
|
config.order = 'random'
|
9
18
|
config.run_all_when_everything_filtered = true
|
19
|
+
|
20
|
+
source_environment_file!
|
10
21
|
end
|
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: 0.
|
4
|
+
version: 0.3.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: 2013-
|
11
|
+
date: 2013-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
@@ -59,6 +59,7 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- .env.sample
|
62
63
|
- .gitignore
|
63
64
|
- .rspec
|
64
65
|
- .travis.yml
|
@@ -73,6 +74,8 @@ files:
|
|
73
74
|
- lib/carrierwave/storage/aws.rb
|
74
75
|
- spec/carrierwave-aws_spec.rb
|
75
76
|
- spec/carrierwave/storage/aws_spec.rb
|
77
|
+
- spec/features/storing_files_spec.rb
|
78
|
+
- spec/fixtures/image.png
|
76
79
|
- spec/spec_helper.rb
|
77
80
|
homepage: https://github.com/sorentwo/carrierwave-aws
|
78
81
|
licenses: []
|
@@ -100,4 +103,6 @@ summary: A slimmer alternative to using Fog for S3 support in CarrierWave
|
|
100
103
|
test_files:
|
101
104
|
- spec/carrierwave-aws_spec.rb
|
102
105
|
- spec/carrierwave/storage/aws_spec.rb
|
106
|
+
- spec/features/storing_files_spec.rb
|
107
|
+
- spec/fixtures/image.png
|
103
108
|
- spec/spec_helper.rb
|