carrierwave-aws 0.2.1 → 0.3.0

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: 022aaea7ed4d3e117c7607e00ce672bf4f299b0d
4
- data.tar.gz: 423d96993911c11c21b443f20086482af5d3072e
3
+ metadata.gz: ec70707302830ad68344002780286686534f2cfe
4
+ data.tar.gz: 5f6a31d07df412d97e8af6c70a7dc4dd89cc8212
5
5
  SHA512:
6
- metadata.gz: d808008e5023f518b901581476e6152c13f9b484d6506c80d8accf9033159ad6e9f90e5d7ff77293a45d02068d2ccdfdbe5f4468f702a869e14b0945f0173924
7
- data.tar.gz: 1fedff06ff918da9b9b808e453b726a8a1fcf3c8624bf18e880409ead4a3a7ac5ef942f01a01e6fca4b5e00259a5654dac251e0001b6d7ca17d1f0ceda2f01ee
6
+ metadata.gz: 3ced29508da5597363c14709224b971e03b8c237a38f830dc2a7aeaaf34d0d1b7cea9489471ca5238dc8576883a8db4e7530fcab0c70d05c6558e8772ded2690
7
+ data.tar.gz: a528306304867a49a75c8052378e43438a5d84ff69485865adb7354ec6073d0e5c1006e4288bf111be31fa9cad006cce535ab2377bb315b691623939c112c362
data/.env.sample ADDED
@@ -0,0 +1,3 @@
1
+ S3_BUCKET_NAME=BUCKET_NAME
2
+ S3_ACCESS_KEY=YOUR_KEY
3
+ S3_SECRET_ACCESS_KEY=YOUR_KEY
data/.gitignore CHANGED
@@ -1,6 +1,8 @@
1
1
  *.gem
2
2
  .bundle
3
3
  .config
4
+ .env
4
5
  Gemfile.lock
5
6
  bin
6
7
  vendor
8
+ uploads
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
+ - 2.0.0
4
5
  script: bundle exec rspec spec
data/HISTORY.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## Version 0.3.0 2013-05-23
2
+
3
+ * Pass the file path directly to aws-sdk to prevent upload timeouts stemming
4
+ incorrect `content_length`.
5
+
1
6
  ## Version 0.2.1 2013-04-20
2
7
 
3
8
  * Provide a `to_file` method on AWS::File in an attempt to prevent errors when
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Carrierwave AWS Storage
2
2
 
3
3
  [![Build Status](https://travis-ci.org/sorentwo/carrierwave-aws.png?branch=master)](https://travis-ci.org/sorentwo/carrierwave-aws)
4
+ [![Code Climate](https://codeclimate.com/github/sorentwo/carrierwave-aws.png)](https://codeclimate.com/github/sorentwo/carrierwave-aws)
5
+ [![Gem Version](https://badge.fury.io/rb/carrierwave-aws.png)](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'`)
@@ -1,5 +1,5 @@
1
1
  module Carrierwave
2
2
  module AWS
3
- VERSION = '0.2.1'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
@@ -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
- aws_file = new_file.to_file
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
- described_class.new(uploader)
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
- described_class.new(uploader, connection, path)
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.2.1
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-04-20 00:00:00.000000000 Z
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