gitlab-org--gitlab-foss/app/services/projects/upload_service.rb
2017-02-21 16:31:14 -06:00

22 lines
449 B
Ruby

module Projects
class UploadService < BaseService
def initialize(project, file)
@project, @file = project, file
end
def execute
return nil unless @file && @file.size <= max_attachment_size
uploader = FileUploader.new(@project)
uploader.store!(@file)
uploader.to_h
end
private
def max_attachment_size
current_application_settings.max_attachment_size.megabytes.to_i
end
end
end