Class: HammerCLIKatello::Repository::UploadContentCommand

Inherits:
InfoCommand
  • Object
show all
Extended by:
HammerCLIKatello::RepositoryScopedToProduct
Includes:
HammerCLIForemanTasks::Helper
Defined in:
lib/hammer_cli_katello/repository.rb

Overview

rubocop:disable ClassLength

Defined Under Namespace

Classes: BinaryPath

Constant Summary collapse

CONTENT_CHUNK_SIZE =

bytes to make sure it’s lower than django’s default 2621440

2_500_000

Instance Method Summary collapse

Methods included from HammerCLIKatello::RepositoryScopedToProduct

validate_repo_name_requires_product_options

Methods included from HammerCLIKatello::ResolverCommons

included

Instance Method Details

#content_upload_resourceObject



370
371
372
# File 'lib/hammer_cli_katello/repository.rb', line 370

def content_upload_resource
  ::HammerCLIForeman.foreman_resource(:content_uploads)
end

#executeObject



353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/hammer_cli_katello/repository.rb', line 353

def execute
  @failure = false
  files = option_content.sort

  if files.length.zero?
    output.print_error _("Could not find any files matching PATH")
    return HammerCLI::EX_NOINPUT
  end

  files.each do |file_path|
    last_file = file_path == files.last
    File.open(file_path, 'rb') { |file| upload_file(file, last_file: last_file) }
  end

  @failure ? HammerCLI::EX_DATAERR : HammerCLI::EX_OK
end

#request_headersObject



349
350
351
# File 'lib/hammer_cli_katello/repository.rb', line 349

def request_headers
  {:content_type => 'multipart/form-data'}
end