Revert fog-aws (ref #5604) (#5934)

This commit is contained in:
Yamagishi Kazutoshi 2017-12-09 08:47:52 +09:00 committed by Eugen Rochko
parent dad0a09675
commit b0db4dad79
3 changed files with 37 additions and 31 deletions

View file

@ -14,7 +14,7 @@ gem 'pg', '~> 0.20'
gem 'pghero', '~> 1.7' gem 'pghero', '~> 1.7'
gem 'dotenv-rails', '~> 2.2' gem 'dotenv-rails', '~> 2.2'
gem 'fog-aws', '~> 1.4', require: false gem 'aws-sdk', '~> 2.10', require: false
gem 'fog-core', '~> 1.45' gem 'fog-core', '~> 1.45'
gem 'fog-local', '~> 0.4', require: false gem 'fog-local', '~> 0.4', require: false
gem 'fog-openstack', '~> 0.1', require: false gem 'fog-openstack', '~> 0.1', require: false

View file

@ -57,6 +57,14 @@ GEM
encryptor (~> 3.0.0) encryptor (~> 3.0.0)
av (0.9.0) av (0.9.0)
cocaine (~> 0.5.3) cocaine (~> 0.5.3)
aws-sdk (2.10.100)
aws-sdk-resources (= 2.10.100)
aws-sdk-core (2.10.100)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.10.100)
aws-sdk-core (= 2.10.100)
aws-sigv4 (1.0.2)
bcrypt (3.1.11) bcrypt (3.1.11)
better_errors (2.4.0) better_errors (2.4.0)
coderay (>= 1.0.0) coderay (>= 1.0.0)
@ -152,11 +160,6 @@ GEM
i18n (~> 0.5) i18n (~> 0.5)
fast_blank (1.0.0) fast_blank (1.0.0)
ffi (1.9.18) ffi (1.9.18)
fog-aws (1.4.1)
fog-core (~> 1.38)
fog-json (~> 1.0)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-core (1.45.0) fog-core (1.45.0)
builder builder
excon (~> 0.58) excon (~> 0.58)
@ -170,9 +173,6 @@ GEM
fog-core (>= 1.40) fog-core (>= 1.40)
fog-json (>= 1.0) fog-json (>= 1.0)
ipaddress (>= 0.8) ipaddress (>= 0.8)
fog-xml (0.1.3)
fog-core
nokogiri (>= 1.5.11, < 2.0.0)
formatador (0.2.5) formatador (0.2.5)
fuubar (2.2.0) fuubar (2.2.0)
rspec-core (~> 3.0) rspec-core (~> 3.0)
@ -228,6 +228,7 @@ GEM
idn-ruby (0.1.0) idn-ruby (0.1.0)
ipaddress (0.8.3) ipaddress (0.8.3)
iso-639 (0.2.8) iso-639 (0.2.8)
jmespath (1.3.1)
json (2.1.0) json (2.1.0)
json-ld (2.1.7) json-ld (2.1.7)
multi_json (~> 1.12) multi_json (~> 1.12)
@ -544,6 +545,7 @@ DEPENDENCIES
active_record_query_trace (~> 1.5) active_record_query_trace (~> 1.5)
addressable (~> 2.5) addressable (~> 2.5)
annotate (~> 2.7) annotate (~> 2.7)
aws-sdk (~> 2.10)
better_errors (~> 2.4) better_errors (~> 2.4)
binding_of_caller (~> 0.7) binding_of_caller (~> 0.7)
bootsnap bootsnap
@ -566,7 +568,6 @@ DEPENDENCIES
fabrication (~> 2.18) fabrication (~> 2.18)
faker (~> 1.7) faker (~> 1.7)
fast_blank (~> 1.0) fast_blank (~> 1.0)
fog-aws (~> 1.4)
fog-core (~> 1.45) fog-core (~> 1.45)
fog-local (~> 0.4) fog-local (~> 0.4)
fog-openstack (~> 0.1) fog-openstack (~> 0.1)

View file

@ -14,40 +14,45 @@ Paperclip::Attachment.default_options.merge!(
) )
if ENV['S3_ENABLED'] == 'true' if ENV['S3_ENABLED'] == 'true'
require 'fog/aws' require 'aws-sdk'
Aws.eager_autoload!(services: %w(S3))
s3_protocol = ENV.fetch('S3_PROTOCOL') { 'https' } s3_region = ENV.fetch('S3_REGION') { 'us-east-1' }
s3_hostname = ENV.fetch('S3_HOSTNAME') { "s3-#{ENV['S3_REGION']}.amazonaws.com" } s3_protocol = ENV.fetch('S3_PROTOCOL') { 'https' }
aws_signature_version = ENV['S3_SIGNATURE_VERSION'] == 's3' ? 2 : ENV['S3_SIGNATURE_VERSION'].to_i s3_hostname = ENV.fetch('S3_HOSTNAME') { "s3-#{s3_region}}.amazonaws.com" }
aws_signature_version = 4 if aws_signature_version.zero?
Paperclip::Attachment.default_options.merge!( Paperclip::Attachment.default_options.merge!(
fog_credentials: { storage: :s3,
provider: 'AWS', s3_protocol: s3_protocol,
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'], s3_host_name: s3_hostname,
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'], s3_headers: {
aws_signature_version: aws_signature_version, 'Cache-Control' => 'max-age=315576000',
region: ENV.fetch('S3_REGION') { 'us-east-1' },
scheme: s3_protocol,
host: s3_hostname
}, },
fog_directory: ENV['S3_BUCKET'], s3_permissions: ENV.fetch('S3_PERMISSION') { 'public-read' },
fog_options: { s3_region: s3_region,
acl: ENV.fetch('S3_PERMISSION') { 'public-read' }, s3_credentials: {
cache_control: 'max-age=315576000', bucket: ENV['S3_BUCKET'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
},
s3_options: {
signature_version: ENV.fetch('S3_SIGNATURE_VERSION') { 'v4' },
} }
) )
if ENV.has_key?('S3_ENDPOINT') if ENV.has_key?('S3_ENDPOINT')
Paperclip::Attachment.default_options[:fog_credentials].merge!( Paperclip::Attachment.default_options[:s3_options].merge!(
endpoint: ENV['S3_ENDPOINT'], endpoint: ENV['S3_ENDPOINT'],
path_style: true force_path_style: true
) )
Paperclip::Attachment.default_options[:fog_host] = "#{s3_protocol}://#{s3_hostname}/#{ENV['S3_BUCKET']}" Paperclip::Attachment.default_options[:url] = ':s3_path_url'
end end
if ENV.has_key?('S3_CLOUDFRONT_HOST') if ENV.has_key?('S3_CLOUDFRONT_HOST')
Paperclip::Attachment.default_options[:fog_host] = "#{s3_protocol}://#{ENV['S3_CLOUDFRONT_HOST']}" Paperclip::Attachment.default_options.merge!(
url: ':s3_alias_url',
s3_host_alias: ENV['S3_CLOUDFRONT_HOST']
)
end end
elsif ENV['SWIFT_ENABLED'] == 'true' elsif ENV['SWIFT_ENABLED'] == 'true'
require 'fog/openstack' require 'fog/openstack'