Method: QcloudCos::ConvenientApi#all

Defined in:
lib/qcloud_cos/convenient_api.rb

#all(path, options = {}) ⇒ Hash

列出所有文件或者目录

Parameters:

  • path (String)

    指定目标路径, 以 / 结尾, 则列出该目录下文件或者文件夹,不以 / 结尾,就搜索该前缀的文件或者文件夹

  • options (Hash) (defaults to: {})

    额外参数

Options Hash (options):

  • :bucket (String) — default: config.bucket_name

    指定当前 bucket, 默认是配置里面的 bucket

  • :pattern (String) — default: eListBoth

    指定拉取的内容,可选值: eListBoth, eListDirOnly, eListFileOnly

  • :order (Integer) — default: 0

    指定拉取文件的顺序, 默认为正序(=0), 可选值: 0, 1

Returns:

  • (Hash)
[View source]

116
117
118
119
120
121
122
123
124
125
# File 'lib/qcloud_cos/convenient_api.rb', line 116

def all(path, options = {})
  results = []
  loop do
    objects = QcloudCos.list(path, options)
    results += objects.to_a
    break unless objects.has_more
    options['context'] = objects.context
  end
  results
end