debian-mirror-gitlab/app/uploaders/avatar_uploader.rb

41 lines
746 B
Ruby
Raw Normal View History

2018-11-08 19:23:39 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
class AvatarUploader < GitlabUploader
2015-11-26 14:37:03 +05:30
include UploaderHelper
2018-03-17 18:26:18 +05:30
include RecordsUploads::Concern
2018-05-09 12:01:36 +05:30
include ObjectStorage::Concern
prepend ObjectStorage::Extension::RecordsUploads
2020-03-13 15:44:24 +05:30
2022-08-27 11:52:29 +05:30
MIME_ALLOWLIST = %w[image/png image/jpeg image/gif image/bmp image/tiff image/vnd.microsoft.icon].freeze
2015-04-26 12:48:37 +05:30
2018-03-17 18:26:18 +05:30
def exists?
model.avatar.file && model.avatar.file.present?
2015-04-26 12:48:37 +05:30
end
2016-08-24 12:49:21 +05:30
2018-05-09 12:01:36 +05:30
def move_to_store
2018-03-17 18:26:18 +05:30
false
2016-08-24 12:49:21 +05:30
end
2017-08-17 22:00:37 +05:30
2018-05-09 12:01:36 +05:30
def move_to_cache
2017-08-17 22:00:37 +05:30
false
end
2018-11-20 20:47:30 +05:30
def absolute_path
2019-12-21 20:55:43 +05:30
self.class.absolute_path(upload)
2018-11-20 20:47:30 +05:30
end
2020-03-13 15:44:24 +05:30
def mounted_as
super || 'avatar'
end
2020-04-08 14:13:33 +05:30
def content_type_whitelist
2022-08-27 11:52:29 +05:30
MIME_ALLOWLIST
2020-04-08 14:13:33 +05:30
end
2018-03-17 18:26:18 +05:30
private
def dynamic_segment
2019-09-04 21:01:54 +05:30
File.join(model.class.underscore, mounted_as.to_s, model.id.to_s)
2017-08-17 22:00:37 +05:30
end
2015-04-26 12:48:37 +05:30
end