Class: AvatarUploader

Inherits:
GitlabUploader show all
Includes:
ObjectStorage::Concern, ObjectStorage::Extension::RecordsUploads, RecordsUploads::Concern, UploaderHelper
Defined in:
app/uploaders/avatar_uploader.rb

Constant Summary collapse

MIME_ALLOWLIST =
%w[image/png image/jpeg image/gif image/bmp image/tiff image/vnd.microsoft.icon].freeze

Constants included from RecordsUploads::Concern

RecordsUploads::Concern::VERSION

Constants included from Gitlab::FileTypeDetection

Gitlab::FileTypeDetection::DANGEROUS_AUDIO_EXT, Gitlab::FileTypeDetection::DANGEROUS_IMAGE_EXT, Gitlab::FileTypeDetection::DANGEROUS_VIDEO_EXT, Gitlab::FileTypeDetection::PDF_EXT, Gitlab::FileTypeDetection::SAFE_AUDIO_EXT, Gitlab::FileTypeDetection::SAFE_IMAGE_EXT, Gitlab::FileTypeDetection::SAFE_IMAGE_FOR_SCALING_EXT, Gitlab::FileTypeDetection::SAFE_VIDEO_EXT

Constants inherited from GitlabUploader

GitlabUploader::ObjectNotReadyError, GitlabUploader::PROTECTED_METHODS

Instance Attribute Summary

Attributes included from RecordsUploads::Concern

#upload

Instance Method Summary collapse

Methods included from ObjectStorage::Concern

#cache!, #delete_migrated_file, #delete_tmp_file_after_storage, #direct_download_enabled?, #exclusive_lease_key, #file_cache_storage?, #file_storage?, #filename, #filename=, #fog_attributes, #fog_credentials, #fog_directory, #fog_public, #migrate!, #object_store, #object_store=, #persist_object_store!, #persist_object_store?, #proxy_download_enabled?, #retrieve_from_store!, #store!, #store_dir, #store_dirs, #store_path, #upload_paths, #use_file, #use_open_file

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from RecordsUploads::Concern

#filename, #readd_upload, #record_upload, #upload_path

Methods included from Gitlab::FileMarkdownLinkBuilder

#markdown_link, #markdown_name

Methods included from Gitlab::FileTypeDetection

#audio?, #dangerous_audio?, #dangerous_embeddable?, #dangerous_image?, #dangerous_video?, #embeddable?, extension_match?, #image?, #image_safe_for_scaling?, #pdf?, #video?

Methods included from ObjectStorage::Extension::RecordsUploads

#build_upload, #exclusive_lease_key, #retrieve_from_store!, #upload=

Methods inherited from GitlabUploader

absolute_path, base_dir, #cache_dir, #cached_size, #check_remote_file_existence_on_upload?, #empty_size?, #file_cache_storage?, file_storage?, #filename, #initialize, #local_url, #model_valid?, #multi_read, #open, #options, options, #relative_path, #replace_file_without_saving!, root, storage_location, #sync_model_object_store?, #url_or_file_path, version, #work_dir

Constructor Details

This class inherits a constructor from GitlabUploader

Instance Method Details

#absolute_pathObject



26
27
28
# File 'app/uploaders/avatar_uploader.rb', line 26

def absolute_path
  self.class.absolute_path(upload)
end

#content_type_whitelistObject



34
35
36
# File 'app/uploaders/avatar_uploader.rb', line 34

def content_type_whitelist
  MIME_ALLOWLIST
end

#exists?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/uploaders/avatar_uploader.rb', line 14

def exists?
  model.avatar.file && model.avatar.file.present?
end

#mounted_asObject



30
31
32
# File 'app/uploaders/avatar_uploader.rb', line 30

def mounted_as
  super || 'avatar'
end

#move_to_cacheObject



22
23
24
# File 'app/uploaders/avatar_uploader.rb', line 22

def move_to_cache
  false
end

#move_to_storeObject



18
19
20
# File 'app/uploaders/avatar_uploader.rb', line 18

def move_to_store
  false
end