Class: Projects::DownloadService

Inherits:
BaseService show all
Defined in:
app/services/projects/download_service.rb

Constant Summary collapse

ALLOWLIST =
[
  /^[^.]+\.fogbugz.com$/
].freeze

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(project, url) ⇒ DownloadService

Returns a new instance of DownloadService.



9
10
11
12
# File 'app/services/projects/download_service.rb', line 9

def initialize(project, url)
  @project = project
  @url = url
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
# File 'app/services/projects/download_service.rb', line 14

def execute
  return unless valid_url?(@url)

  uploader = FileUploader.new(@project)
  uploader.download!(@url)
  uploader.store!

  uploader.to_h
end