Class: Projects::DownloadService

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

Constant Summary collapse

WHITELIST =
[
  /^[^.]+\.fogbugz.com$/
]

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#abilities, #can?, #deny_visibility_level, #event_service, #log_info, #notification_service, #repository, #system_hook_service, #todo_service

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Constructor Details

#initialize(project, url) ⇒ DownloadService

Returns a new instance of DownloadService


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

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

Instance Method Details

#executeObject


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

def execute
  return nil unless valid_url?(@url)

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

  uploader.to_h
end