Class: Fog::Storage::Aliyun::Directories

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/aliyun/models/storage/directories.rb

Instance Method Summary collapse

Instance Method Details

#allObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/aliyun/models/storage/directories.rb', line 10

def all
  containers = service.get_containers
  return nil if nil == containers
  data = []
  i = 0
  containers.each do |entry|
    key = entry['Prefix'][0]
    key[-1] = ''
    data[i] = { key: key }
    i += 1
  end

  load(data)
end

#get(key, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/aliyun/models/storage/directories.rb', line 25

def get(key, options = {})
  if !key.nil? && key != '' && key != '.'
    dir = key + '/'
    ret = service.head_object(dir, options)
    new(key: key) if ret.data[:status] == 200
  else
    new(key: '')
  end
rescue Fog::Storage::Aliyun::NotFound
  nil
end