Class: DTK::Network::Client::S3Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/client/s3_helper.rb

Class Method Summary collapse

Class Method Details

.ret_s3_bucket_info(response) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/client/s3_helper.rb', line 3

def self.ret_s3_bucket_info(response)
  branch = response['branch'] || {}
  bucket = nil
  object_name = nil

  if meta = branch['meta']
    catalog_uri = meta['catalog_uri']
    if match = catalog_uri.match(/.*amazonaws.com\/([^\/]*)\/(.*.gz)/)
      bucket = match[1]
      object_name = match[2]
    end
  else
    raise "Unexpected that publish response does not contain branch metadata!"
  end

  raise "Unable to extract bucket and/or object name data from catalog_uri!" if bucket.nil? || object_name.nil?

  return [bucket, object_name]
end