Method: QcloudCos::ConvenientApi#count

Defined in:
lib/qcloud_cos/convenient_api.rb

#count(path = '/', options = {}) ⇒ Hash

返回该路径下文件和文件夹的数目

Examples:

QcloudCos.count('/path/to/folder/') #=> { folder_count: 100, file_count: 1000 }

Parameters:

  • path (String) (defaults to: '/')

    指定路径

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

    额外参数

Options Hash (options):

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

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

Returns:

  • (Hash)
[View source]

25
26
27
28
29
30
31
# File 'lib/qcloud_cos/convenient_api.rb', line 25

def count(path = '/', options = {})
  result = list_folders(path, options.merge(num: 1))
  {
    folder_count: result.dircount || 0,
    file_count: result.filecount || 0
  }
end