Commit 572bba0e by Wojciech Wnętrzak Committed by Sid Raval

aws-sdk-s3 instead of aws-sdk (#2481)

* Added support for aws-sdk-s3 gem which is now preferred way to interact with s3.

Reference: https://github.com/aws/aws-sdk-ruby/blob/master/V3_UPGRADING_GUIDE.md#library-maintainer

* Drop support for aws-sdk gem
parent de92a5a4
......@@ -567,7 +567,7 @@ Storage
Paperclip ships with 3 storage adapters:
* File Storage
* S3 Storage (via `aws-sdk`)
* S3 Storage (via `aws-sdk-s3`)
* Fog Storage
If you would like to use Paperclip with another storage, you can install these
......@@ -593,10 +593,10 @@ _**NOTE**: This is a change from previous versions of Paperclip, but is overall
safer choice for the default file store._
You may also choose to store your files using Amazon's S3 service. To do so, include
the `aws-sdk` gem in your Gemfile:
the `aws-sdk-s3` gem in your Gemfile:
```ruby
gem 'aws-sdk', '~> 2.3.0'
gem 'aws-sdk-s3'
```
And then you can specify using S3 from `has_attached_file`.
......
......@@ -17,7 +17,7 @@ Given /^I generate a new rails application$/ do
gem "jruby-openssl", :platform => :jruby
gem "capybara"
gem "gherkin"
gem "aws-sdk", "~> 2.0.0"
gem "aws-sdk-s3"
gem "racc", :platform => :rbx
gem "rubysl", :platform => :rbx
"""
......
......@@ -3,8 +3,8 @@ module Paperclip
# Amazon's S3 file hosting service is a scalable, easy place to store files for
# distribution. You can find out more about it at http://aws.amazon.com/s3
#
# To use Paperclip with S3, include the +aws-sdk+ gem in your Gemfile:
# gem 'aws-sdk'
# To use Paperclip with S3, include the +aws-sdk-s3+ gem in your Gemfile:
# gem 'aws-sdk-s3'
# There are a few S3-specific options for has_attached_file:
# * +s3_credentials+: Takes a path, a File, a Hash or a Proc. The path (or File) must point
# to a YAML file containing the +access_key_id+ and +secret_access_key+ that Amazon
......@@ -96,7 +96,7 @@ module Paperclip
# separate parts of your file name.
# * +s3_host_name+: If you are using your bucket in Tokyo region
# etc, write host_name (e.g., 's3-ap-northeast-1.amazonaws.com').
# * +s3_region+: For aws-sdk v2, s3_region is required.
# * +s3_region+: For aws-sdk-s3, s3_region is required.
# * +s3_metadata+: These key/value pairs will be stored with the
# object. This option works by prefixing each key with
# "x-amz-meta-" before sending it as a header on the object
......@@ -118,20 +118,16 @@ module Paperclip
# :s3_storage_class => :REDUCED_REDUNDANCY
#
# Other storage classes, such as <tt>:STANDARD_IA</tt>, are also available—see the
# documentation for the <tt>aws-sdk</tt> gem for the full list.
# documentation for the <tt>aws-sdk-s3</tt> gem for the full list.
module S3
def self.extended base
begin
require 'aws-sdk'
require "aws-sdk-s3"
rescue LoadError => e
e.message << " (You may need to install the aws-sdk gem)"
e.message << " (You may need to install the aws-sdk-s3 gem)"
raise e
end
if Gem::Version.new(Aws::VERSION) >= Gem::Version.new(2) &&
Gem::Version.new(Aws::VERSION) <= Gem::Version.new("2.0.33")
raise LoadError, "paperclip does not support aws-sdk versions 2.0.0 - 2.0.33. Please upgrade aws-sdk to a newer version."
end
base.instance_eval do
@s3_options = @options[:s3_options] || {}
......@@ -159,11 +155,6 @@ module Paperclip
@http_proxy = @options[:http_proxy] || nil
if @options.has_key?(:use_accelerate_endpoint) &&
Gem::Version.new(Aws::VERSION) < Gem::Version.new("2.3.0")
raise LoadError, ":use_accelerate_endpoint is only available from aws-sdk version 2.3.0. Please upgrade aws-sdk to a newer version."
end
@use_accelerate_endpoint = @options[:use_accelerate_endpoint]
end
......
......@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
s.add_development_dependency('rspec', '~> 3.0')
s.add_development_dependency('appraisal')
s.add_development_dependency('mocha')
s.add_development_dependency('aws-sdk', '>= 2.3.0', '< 3.0')
s.add_development_dependency('aws-sdk-s3')
s.add_development_dependency('bourne')
s.add_development_dependency('cucumber-rails')
s.add_development_dependency('cucumber-expressions', '4.0.3') # TODO: investigate failures on 4.0.4
......
require 'spec_helper'
require 'aws-sdk'
require "spec_helper"
require "aws-sdk-s3"
describe Paperclip::Storage::S3 do
before do
......@@ -237,7 +237,7 @@ describe Paperclip::Storage::S3 do
end
end
# if using aws-sdk-v2, the s3_host_name will be defined by the s3_region
# the s3_host_name will be defined by the s3_region
context "s3_host_name" do
before do
rebuild_model storage: :s3,
......@@ -282,7 +282,7 @@ describe Paperclip::Storage::S3 do
end
end
context "use_accelerate_endpoint", if: aws_accelerate_available? do
context "use_accelerate_endpoint" do
context "defaults to false" do
before do
rebuild_model(
......@@ -308,7 +308,7 @@ describe Paperclip::Storage::S3 do
end
end
context "set to true", if: aws_accelerate_available? do
context "set to true" do
before do
rebuild_model(
storage: :s3,
......@@ -793,7 +793,7 @@ describe Paperclip::Storage::S3 do
end
end
# for aws-sdk-v2 the bucket.name is determined by the :s3_region
# the bucket.name is determined by the :s3_region
context "Parsing S3 credentials with a s3_host_name in them" do
before do
rebuild_model storage: :s3,
......
......@@ -39,7 +39,6 @@ RSpec.configure do |config|
config.include TestData
config.include Reporting
config.extend VersionHelper
config.extend ConditionalFilterHelper
config.mock_framework = :mocha
config.before(:all) do
rebuild_model
......
module ConditionalFilterHelper
def aws_accelerate_available?
(Gem::Version.new(Aws::VERSION) >= Gem::Version.new("2.3.0"))
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment