2018-07-04 13:32:46 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-18 10:31:44 -04:00
|
|
|
class AttachmentUploader < GitlabUploader
|
2018-02-02 08:59:43 -05:00
|
|
|
include RecordsUploads::Concern
|
|
|
|
include ObjectStorage::Concern
|
|
|
|
prepend ObjectStorage::Extension::RecordsUploads
|
2018-03-02 16:19:17 -05:00
|
|
|
include UploaderHelper
|
2015-11-14 13:29:58 -05:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
private
|
2011-10-08 17:36:38 -04:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
def dynamic_segment
|
2019-05-11 08:06:44 -04:00
|
|
|
File.join(model.class.underscore, mounted_as.to_s, model.id.to_s)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
2020-03-12 20:09:34 -04:00
|
|
|
|
|
|
|
def mounted_as
|
|
|
|
# Geo fails to sync attachments on Note, and LegacyDiffNotes with missing mount_point.
|
|
|
|
#
|
|
|
|
# See https://gitlab.com/gitlab-org/gitlab/-/issues/209752 for more details.
|
|
|
|
if model.class.underscore.include?('note')
|
|
|
|
super || 'attachment'
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|