1# frozen_string_literal: true
2
3class AvatarUploader < GitlabUploader
4  include UploaderHelper
5  include RecordsUploads::Concern
6  include ObjectStorage::Concern
7  prepend ObjectStorage::Extension::RecordsUploads
8
9  MIME_WHITELIST = %w[image/png image/jpeg image/gif image/bmp image/tiff image/vnd.microsoft.icon].freeze
10
11  def exists?
12    model.avatar.file && model.avatar.file.present?
13  end
14
15  def move_to_store
16    false
17  end
18
19  def move_to_cache
20    false
21  end
22
23  def absolute_path
24    self.class.absolute_path(upload)
25  end
26
27  def mounted_as
28    super || 'avatar'
29  end
30
31  def content_type_whitelist
32    MIME_WHITELIST
33  end
34
35  private
36
37  def dynamic_segment
38    File.join(model.class.underscore, mounted_as.to_s, model.id.to_s)
39  end
40end
41