From 497311023be831e19cc27bd93c00d8f66368ec63 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sun, 16 Dec 2018 16:24:17 -0800 Subject: [PATCH] Fix object storage not working properly with Google S3 compatibility Even in AWS S3 compatibility mode, Google now appears to reject requests that includes this header with this error: ``` Requests cannot specify both x-amz and x-goog headers ``` This has been submitted upstream via https://github.com/carrierwaveuploader/carrierwave/pull/2356. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/53846. --- .../unreleased/sh-carrierwave-patch-google-acl.yml | 5 +++++ config/initializers/carrierwave_patch.rb | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 changelogs/unreleased/sh-carrierwave-patch-google-acl.yml diff --git a/changelogs/unreleased/sh-carrierwave-patch-google-acl.yml b/changelogs/unreleased/sh-carrierwave-patch-google-acl.yml new file mode 100644 index 000000000000..e8ae9f7d103c --- /dev/null +++ b/changelogs/unreleased/sh-carrierwave-patch-google-acl.yml @@ -0,0 +1,5 @@ +--- +title: Fix Carrierwave not working properly with Google S3 compatibility +merge_request: 23858 +author: +type: fixed diff --git a/config/initializers/carrierwave_patch.rb b/config/initializers/carrierwave_patch.rb index 35ffff03abeb..c361784491dd 100644 --- a/config/initializers/carrierwave_patch.rb +++ b/config/initializers/carrierwave_patch.rb @@ -23,6 +23,19 @@ def authenticated_url(options = {}) end end end + + # Fix for https://github.com/carrierwaveuploader/carrierwave/pull/2356 + def acl_header + if fog_provider == 'AWS' + { 'x-amz-acl' => @uploader.fog_public ? 'public-read' : 'private' } + else + {} + end + end + + def fog_provider + @uploader.fog_credentials[:provider].to_s + end end end end