gitlab-org--gitlab-foss/app/services/projects/upload_service.rb

23 lines
450 B
Ruby
Raw Normal View History

2015-02-16 13:58:40 -05:00
module Projects
class UploadService < BaseService
def initialize(project, file)
@project, @file = project, file
end
def execute
return nil unless @file and @file.size <= max_attachment_size
2015-02-16 13:58:40 -05:00
uploader = FileUploader.new(@project)
uploader.store!(@file)
2016-01-08 11:38:53 -05:00
uploader.to_h
2015-02-16 13:58:40 -05:00
end
private
def max_attachment_size
current_application_settings.max_attachment_size.megabytes.to_i
end
2015-02-16 13:58:40 -05:00
end
end