Class: Projects::UploadService

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

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, file) ⇒ UploadService

Returns a new instance of UploadService


3
4
5
# File 'app/services/projects/upload_service.rb', line 3

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

Instance Method Details

#executeObject


7
8
9
10
11
12
13
14
# File 'app/services/projects/upload_service.rb', line 7

def execute
  return nil unless @file and @file.size <= max_attachment_size

  uploader = FileUploader.new(@project)
  uploader.store!(@file)

  uploader.to_h
end