From 94a815a9ef53f940f171fdb3af6cbf706b73d562 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 22 Oct 2020 18:16:47 +0100 Subject: [PATCH] Upgrade aws-sdk and set s3 host name using the provided url config. This will enable us to set hostnames with the s3 region defined and that will make our image upload work for all s3 regions. --- Gemfile | 2 +- Gemfile.lock | 10 +++++----- app/models/spree/image.rb | 5 +++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index f5e229439e..944b9b3ed1 100644 --- a/Gemfile +++ b/Gemfile @@ -58,7 +58,7 @@ gem 'kaminari', '~> 0.14.1' gem 'andand' gem 'angularjs-rails', '1.5.5' -gem 'aws-sdk', '1.11.1' # temporarily locked down due to https://github.com/aws/aws-sdk-ruby/issues/273 +gem 'aws-sdk', '1.67.0' gem 'bugsnag' gem 'db2fog' gem 'haml' diff --git a/Gemfile.lock b/Gemfile.lock index 456bb05829..0a132c0247 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -117,10 +117,11 @@ GEM awesome_nested_set (3.0.3) activerecord (>= 4.0.0, < 5) awesome_print (1.8.0) - aws-sdk (1.11.1) + aws-sdk (1.67.0) + aws-sdk-v1 (= 1.67.0) + aws-sdk-v1 (1.67.0) json (~> 1.4) - nokogiri (>= 1.4.4) - uuidtools (~> 2.1) + nokogiri (~> 1) bcrypt (3.1.13) bugsnag (6.18.0) concurrent-ruby (~> 1.0) @@ -648,7 +649,6 @@ GEM unicorn-worker-killer (0.4.4) get_process_mem (~> 0) unicorn (>= 4, < 6) - uuidtools (2.1.5) warden (1.2.7) rack (>= 1.0) webdrivers (4.2.0) @@ -688,7 +688,7 @@ DEPENDENCIES atomic awesome_nested_set (~> 3.0.0.rc.1) awesome_print - aws-sdk (= 1.11.1) + aws-sdk (= 1.67.0) bugsnag byebug (~> 11.0.0) cancan (~> 1.6.10) diff --git a/app/models/spree/image.rb b/app/models/spree/image.rb index 8af54e443b..a8ea22038a 100644 --- a/app/models/spree/image.rb +++ b/app/models/spree/image.rb @@ -61,6 +61,11 @@ module Spree set_attachment_attributes(:s3_headers, ActiveSupport::JSON.decode(Spree::Config[:s3_headers])) set_attachment_attributes(:bucket, Spree::Config[:s3_bucket]) + + # When using S3, we set the URL on property s3_host_name + set_attachment_attributes(:s3_host_name, attachment_definitions[:attachment][:url]) + set_attachment_attributes(:url, ":s3_domain_url") + # :s3_alias_url else attachment_definitions[:attachment].delete :storage end