Class: Aspera::Fasp::HttpGW

Inherits:
Manager
  • Object
show all
Defined in:
lib/aspera/fasp/http_gw.rb

Overview

executes a local “ascp”, connects mgt port, equivalent of “Fasp Manager”

Constant Summary

Constants inherited from Manager

Manager::LISTENER_SESSION_ID_B, Manager::LISTENER_SESSION_ID_S

Instance Method Summary collapse

Methods inherited from Manager

#add_listener, validate_status_list

Instance Method Details

#shutdownObject

terminates monitor thread



61
62
# File 'lib/aspera/fasp/http_gw.rb', line 61

def shutdown
end

#start_transfer(transfer_spec, options = {}) ⇒ Object

start FASP transfer based on transfer spec (hash table) note that it is asynchronous HTTP download only supports file list



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/aspera/fasp/http_gw.rb', line 14

def start_transfer(transfer_spec,options={})
  raise "GW URL must be set" unless !@gw_api.nil?
  raise "option: must be hash (or nil)" unless options.is_a?(Hash)
  raise "paths: must be Array" unless transfer_spec['paths'].is_a?(Array)
  case transfer_spec['direction']
  when 'send'
    # this is a websocket
    raise "error, not implemented"
  when 'receive'
    transfer_spec['zip_required']||=false
    transfer_spec['authentication']||='token'
    transfer_spec['source_root']||='/'
    # is normally provided by application, like package name
    if !transfer_spec.has_key?('download_name')
      # by default it is the name of first file
      dname=File.basename(transfer_spec['paths'].first['source'])
      # we remove extension
      dname=dname.gsub(/\.@gw_api.*$/,'')
      # ands add indication of number of files if there is more than one
      if transfer_spec['paths'].length > 1
        dname=dname+" #{transfer_spec['paths'].length} Files"
      end
      transfer_spec['download_name']=dname
    end
    creation=@gw_api.create('download',{'transfer_spec'=>transfer_spec})[:data]
    transfer_uuid=creation['url'].split('/').last
    if transfer_spec['zip_required'] or transfer_spec['paths'].length > 1
      # it is a zip file if zip is required or there is more than 1 file
      file_dest=transfer_spec['download_name']+'.zip'
    else
      # it is a plain file if we don't require zip and there is only one file
      file_dest=File.basename(transfer_spec['paths'].first['source'])
    end
    file_dest=File.join(transfer_spec['destination_root'],file_dest)
    @gw_api.call({:operation=>'GET',:subpath=>"download/#{transfer_uuid}",:save_to_file=>file_dest})
  else
    raise "error"
  end
end

#url=(api_url) ⇒ Object



64
65
# File 'lib/aspera/fasp/http_gw.rb', line 64

def url=(api_url)
end

#wait_for_transfers_completionObject

wait for completion of all jobs started

Returns:

  • list of :success or error message



56
57
58
# File 'lib/aspera/fasp/http_gw.rb', line 56

def wait_for_transfers_completion
  return [:success]
end