diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /lib/object_storage | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'lib/object_storage')
-rw-r--r-- | lib/object_storage/direct_upload.rb | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/object_storage/direct_upload.rb b/lib/object_storage/direct_upload.rb index 5eab882039d..76f92f62e9c 100644 --- a/lib/object_storage/direct_upload.rb +++ b/lib/object_storage/direct_upload.rb @@ -23,9 +23,9 @@ module ObjectStorage MINIMUM_MULTIPART_SIZE = 5.megabytes attr_reader :credentials, :bucket_name, :object_name - attr_reader :has_length, :maximum_size + attr_reader :has_length, :maximum_size, :consolidated_settings - def initialize(credentials, bucket_name, object_name, has_length:, maximum_size: nil) + def initialize(credentials, bucket_name, object_name, has_length:, maximum_size: nil, consolidated_settings: false) unless has_length raise ArgumentError, 'maximum_size has to be specified if length is unknown' unless maximum_size end @@ -35,6 +35,7 @@ module ObjectStorage @object_name = object_name @has_length = has_length @maximum_size = maximum_size + @consolidated_settings = consolidated_settings end def to_hash @@ -80,10 +81,12 @@ module ObjectStorage end def use_workhorse_s3_client? - Feature.enabled?(:use_workhorse_s3_client, default_enabled: true) && - credentials.fetch(:use_iam_profile, false) && - # The Golang AWS SDK does not support V2 signatures - credentials.fetch(:aws_signature_version, 4).to_i >= 4 + return false unless Feature.enabled?(:use_workhorse_s3_client, default_enabled: true) + return false unless credentials.fetch(:use_iam_profile, false) || consolidated_settings + # The Golang AWS SDK does not support V2 signatures + return false unless credentials.fetch(:aws_signature_version, 4).to_i >= 4 + + true end def provider @@ -92,7 +95,11 @@ module ObjectStorage # Implements https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html def get_url - connection.get_object_url(bucket_name, object_name, expire_at) + if google? + connection.get_object_https_url(bucket_name, object_name, expire_at) + else + connection.get_object_url(bucket_name, object_name, expire_at) + end end # Implements https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html @@ -166,6 +173,10 @@ module ObjectStorage provider == 'AWS' end + def google? + provider == 'Google' + end + def requires_multipart_upload? aws? && !has_length end |