Class: UploaderFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/uploader_finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(project, secret, file_path) ⇒ UploaderFinder

Instantiates a a new FileUploader FileUploader can be opened via .open agnostic of storage type Arguments correspond to Upload.secret, Upload.model_type and Upload.file_path Returns a FileUploader with uploaded file retrieved into the object state



8
9
10
11
12
# File 'app/finders/uploader_finder.rb', line 8

def initialize(project, secret, file_path)
  @project = project
  @secret = secret
  @file_path = file_path
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
# File 'app/finders/uploader_finder.rb', line 14

def execute
  prevent_path_traversal_attack!
  retrieve_file_state!

  uploader
rescue ::Gitlab::PathTraversal::PathTraversalAttackError
  nil # no-op if for incorrect files
end

#prevent_path_traversal_attack!Object



23
24
25
# File 'app/finders/uploader_finder.rb', line 23

def prevent_path_traversal_attack!
  Gitlab::PathTraversal.check_path_traversal!(@file_path)
end

#retrieve_file_state!Object



27
28
29
# File 'app/finders/uploader_finder.rb', line 27

def retrieve_file_state!
  uploader.retrieve_from_store!(@file_path)
end

#uploaderObject



31
32
33
# File 'app/finders/uploader_finder.rb', line 31

def uploader
  @uploader ||= FileUploader.new(@project, secret: @secret)
end