summaryrefslogtreecommitdiff
path: root/lib/object_storage/direct_upload.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/object_storage/direct_upload.rb')
-rw-r--r--lib/object_storage/direct_upload.rb30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/object_storage/direct_upload.rb b/lib/object_storage/direct_upload.rb
index fd26663fef0..5eab882039d 100644
--- a/lib/object_storage/direct_upload.rb
+++ b/lib/object_storage/direct_upload.rb
@@ -2,7 +2,7 @@
module ObjectStorage
#
- # The DirectUpload c;ass generates a set of presigned URLs
+ # The DirectUpload class generates a set of presigned URLs
# that can be used to upload data to object storage from untrusted component: Workhorse, Runner?
#
# For Google it assumes that the platform supports variable Content-Length.
@@ -46,7 +46,7 @@ module ObjectStorage
MultipartUpload: multipart_upload_hash,
CustomPutHeaders: true,
PutHeaders: upload_options
- }.compact
+ }.merge(workhorse_client_hash).compact
end
def multipart_upload_hash
@@ -60,6 +60,32 @@ module ObjectStorage
}
end
+ def workhorse_client_hash
+ return {} unless aws?
+
+ {
+ UseWorkhorseClient: use_workhorse_s3_client?,
+ RemoteTempObjectID: object_name,
+ ObjectStorage: {
+ Provider: 'AWS',
+ S3Config: {
+ Bucket: bucket_name,
+ Region: credentials[:region],
+ Endpoint: credentials[:endpoint],
+ PathStyle: credentials.fetch(:path_style, false),
+ UseIamProfile: credentials.fetch(:use_iam_profile, false)
+ }
+ }
+ }
+ 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
+ end
+
def provider
credentials[:provider].to_s
end