Method: QcloudCos::Cli#list

Defined in:
lib/qcloud_cos/cli.rb

#list(args, options) ⇒ Object

列出文件或者文件夹使用: $ qcloud-cos list [options] [dest_path]

Examples:


# 列出 / 下面的所有对象
qcloud-cos list

# 列出 /test/ 下面的所有对象
qcloud-cos list /test/

# 列出 /test/ 下面的前 10 个对象
qcloud-cos list --num 10 /test/

# 列出 bucket2 的 /test/ 下面的所有对象
qcloud-cos list --bucket bucket2 /test/


107
108
109
110
111
112
113
114
115
116
# File 'lib/qcloud_cos/cli.rb', line 107

def list(args, options)
  path = args.shift || '/'
  opts = parse(options)
  opts[:num] = options.num || 100

  objects = QcloudCos.list(path, opts)
  objects.map do |object|
    File.join(path, object.is_a?(QcloudCos::FolderObject) ? "#{object.name}/" : object.name)
  end
end