diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 13:49:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 13:49:51 +0000 |
commit | 71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch) | |
tree | 6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /app/uploaders | |
parent | a7253423e3403b8c08f8a161e5937e1488f5f407 (diff) | |
download | gitlab-ce-71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e.tar.gz |
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'app/uploaders')
-rw-r--r-- | app/uploaders/attachment_uploader.rb | 12 | ||||
-rw-r--r-- | app/uploaders/object_storage/cdn.rb | 2 | ||||
-rw-r--r-- | app/uploaders/object_storage/s3.rb | 14 |
3 files changed, 21 insertions, 7 deletions
diff --git a/app/uploaders/attachment_uploader.rb b/app/uploaders/attachment_uploader.rb index 47de6fe0fbd..9b142dbe4b8 100644 --- a/app/uploaders/attachment_uploader.rb +++ b/app/uploaders/attachment_uploader.rb @@ -6,12 +6,6 @@ class AttachmentUploader < GitlabUploader prepend ObjectStorage::Extension::RecordsUploads include UploaderHelper - private - - def dynamic_segment - File.join(model.class.underscore, mounted_as.to_s, model.id.to_s) - end - def mounted_as # Geo fails to sync attachments on Note, and LegacyDiffNotes with missing mount_point. # @@ -22,4 +16,10 @@ class AttachmentUploader < GitlabUploader super end end + + private + + def dynamic_segment + File.join(model.class.underscore, mounted_as.to_s, model.id.to_s) + end end diff --git a/app/uploaders/object_storage/cdn.rb b/app/uploaders/object_storage/cdn.rb index 8c9ee8682f4..a117451b3f8 100644 --- a/app/uploaders/object_storage/cdn.rb +++ b/app/uploaders/object_storage/cdn.rb @@ -16,7 +16,7 @@ module ObjectStorage if use_cdn?(ip_address) UrlResult.new(cdn_signed_url(params), true) else - UrlResult.new(url, false) + UrlResult.new(url(query: params), false) end end diff --git a/app/uploaders/object_storage/s3.rb b/app/uploaders/object_storage/s3.rb new file mode 100644 index 00000000000..063af8b5389 --- /dev/null +++ b/app/uploaders/object_storage/s3.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module ObjectStorage + module S3 + def self.signed_head_url(file) + fog_storage = ::Fog::Storage.new(file.fog_credentials) + fog_dir = fog_storage.directories.new(key: file.fog_directory) + fog_file = fog_dir.files.new(key: file.path) + expire_at = ::Fog::Time.now + file.fog_authenticated_url_expiration + + fog_file.collection.head_url(fog_file.key, expire_at) + end + end +end |