Class: NamespaceFileUploader

Inherits:
FileUploader show all
Defined in:
app/uploaders/namespace_file_uploader.rb

Constant Summary

Constants inherited from FileUploader

FileUploader::DYNAMIC_PATH_PATTERN, FileUploader::InvalidSecret, FileUploader::MARKDOWN_PATTERN, FileUploader::VALID_SECRET_PATTERN

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 inherited from FileUploader

#model

Attributes included from RecordsUploads::Concern

#upload

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FileUploader

absolute_base_dir, absolute_path, #absolute_path, #base_dir, #copy_file, copy_to, extract_dynamic_path, generate_secret, #initialize, #initialize_copy, #local_storage_path, relative_path, #remote_storage_path, #secret, #store_dirs, #to_h, #upload=, #upload_path, #upload_paths

Methods included from ObjectStorage::Concern

#cache!, #delete_migrated_file, #delete_tmp_file_after_storage, #exclusive_lease_key, #exists?, #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?, #retrieve_from_store!, #store!, #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, #cache_dir, #cached_size, #exists?, #file_cache_storage?, file_storage?, #filename, #initialize, #local_url, #model_valid?, #move_to_cache, #move_to_store, #multi_read, #open, #options, options, #relative_path, #replace_file_without_saving!, storage_location, #url_or_file_path, version, #work_dir

Constructor Details

This class inherits a constructor from FileUploader

Class Method Details

.base_dir(model, store = nil) ⇒ Object



9
10
11
# File 'app/uploaders/namespace_file_uploader.rb', line 9

def self.base_dir(model, store = nil)
  base_dirs(model)[store || Store::LOCAL]
end

.base_dirs(model) ⇒ Object



13
14
15
16
17
18
# File 'app/uploaders/namespace_file_uploader.rb', line 13

def self.base_dirs(model)
  {
    Store::LOCAL => File.join(options.base_dir, 'namespace', model_path_segment(model)),
    Store::REMOTE => File.join('namespace', model_path_segment(model))
  }
end

.model_path_segment(model) ⇒ Object



20
21
22
# File 'app/uploaders/namespace_file_uploader.rb', line 20

def self.model_path_segment(model)
  File.join(model.id.to_s)
end

.rootObject

Re-Override



5
6
7
# File 'app/uploaders/namespace_file_uploader.rb', line 5

def self.root
  options.storage_path
end

.workhorse_local_upload_pathObject



24
25
26
# File 'app/uploaders/namespace_file_uploader.rb', line 24

def self.workhorse_local_upload_path
  File.join(options.storage_path, 'uploads', TMP_UPLOAD_PATH)
end

Instance Method Details

#store_dirObject

Re-Override



29
30
31
# File 'app/uploaders/namespace_file_uploader.rb', line 29

def store_dir
  store_dirs[object_store]
end