Class: Etna::Clients::Metis::MetisUploadWorkflow

Inherits:
Struct
  • Object
show all
Defined in:
lib/etna/clients/metis/workflows/metis_upload_workflow.rb

Defined Under Namespace

Classes: Upload

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ MetisUploadWorkflow

Returns a new instance of MetisUploadWorkflow.



12
13
14
# File 'lib/etna/clients/metis/workflows/metis_upload_workflow.rb', line 12

def initialize(args)
  super({max_attempts: 3, metis_uid: SecureRandom.hex}.update(args))
end

Instance Attribute Details

#bucket_nameObject

Returns the value of attribute bucket_name

Returns:

  • (Object)

    the current value of bucket_name



10
11
12
# File 'lib/etna/clients/metis/workflows/metis_upload_workflow.rb', line 10

def bucket_name
  @bucket_name
end

#max_attemptsObject

Returns the value of attribute max_attempts

Returns:

  • (Object)

    the current value of max_attempts



10
11
12
# File 'lib/etna/clients/metis/workflows/metis_upload_workflow.rb', line 10

def max_attempts
  @max_attempts
end

#metis_clientObject

Returns the value of attribute metis_client

Returns:

  • (Object)

    the current value of metis_client



10
11
12
# File 'lib/etna/clients/metis/workflows/metis_upload_workflow.rb', line 10

def metis_client
  @metis_client
end

#metis_uidObject

Returns the value of attribute metis_uid

Returns:

  • (Object)

    the current value of metis_uid



10
11
12
# File 'lib/etna/clients/metis/workflows/metis_upload_workflow.rb', line 10

def metis_uid
  @metis_uid
end

#project_nameObject

Returns the value of attribute project_name

Returns:

  • (Object)

    the current value of project_name



10
11
12
# File 'lib/etna/clients/metis/workflows/metis_upload_workflow.rb', line 10

def project_name
  @project_name
end

Instance Method Details

#do_upload(source_file, dest_path, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/etna/clients/metis/workflows/metis_upload_workflow.rb', line 16

def do_upload(source_file, dest_path, &block)
  upload = Upload.new(source_file: source_file)

  dir = ::File.dirname(dest_path)
  metis_client.create_folder(CreateFolderRequest.new(
      project_name: project_name,
      bucket_name: bucket_name,
      folder_path: dir,
  ))

  authorize_response = metis_client.authorize_upload(AuthorizeUploadRequest.new(
      project_name: project_name,
      bucket_name: bucket_name,
      file_path: dest_path,
  ))

  upload_parts(upload, authorize_response.upload_path, &block)
end