列出目录
all = bucket.list all.each do |o| if o.is_a?(COS::COSFile) puts "File: #{o.name} #{o.format_size}" else puts "Dir: #{o.name} #{o.created_at}" end end
Parameters:
目录路径, 如: ‘/’, ‘path1’, ‘path1/path2’, sdk会补齐末尾的 ‘/’
Options Hash (options):
搜索前缀如果填写prefix, 则列出含此前缀的所有文件及目录
每页拉取的数量, 默认20条
获取方式:dir_only 只获取目录, :file_only 只获取文件, 默认为 :both 全部获取
排序方式 :asc 正序, :desc 倒序 默认为 :asc
Returns:
迭代器, 其中Object可能是COS::COSFile或COS::COSDir
Raises:
服务端异常返回
168 169 170
# File 'lib/cos/bucket.rb', line 168 def list(path = '', options = {}) Resource.new(self, path, options).to_enum end