Updated on 2026-02-12 GMT+08:00

Collecting Folder Statistics

Function

Collect statistics on the number of directories, number of files, and total file size in a folder.

URI

GET /koodrive/ose/v1/files/statsDir

Table 1 Query Parameters

Parameter

Mandatory

Type

Description

fileId

Yes

String

Definition:

Directory ID. The root directory is supported.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

containerId

Yes

String

Definition:

ID of the space to which the directory belongs.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

recursive

No

Boolean

Definition:

Whether to recursively collect statistics on files.

If files are collected recursively, all subdirectories and files are collected.

If not, only the direct subdirectories and subfiles in a specified directory are collected.

Constraints:

N/A

Range:

true,false

Default Value:

true

includeDirCount

No

Boolean

Definition:

Whether to count the total number of subdirectories.

Constraints:

N/A

Range:

true,false

Default Value:

true

includeFileCount

No

Boolean

Definition:

Whether to count the total number of subfiles.

Constraints:

N/A

Range:

true,false

Default Value:

true

includeTotalSize

No

Boolean

Definition:

Whether to count the total file size.

Constraints:

N/A

Range:

true,false

Default Value:

true

type

No

Integer

Definition:

Filter files by type.

Constraints:

N/A

Range:

Enumerated value 1: common file 2. Directory file (If this parameter is not transferred or is left empty, all types are collected.)

Default Value:

N/A

extensions

No

String

Definition:

List of file name extensions to be filtered. Note that file name extensions are case-insensitive. For example, the search results of JPG and jpg are the same.

Constraints:

This parameter is valid only for subfiles. Extensions are separated by commas (,), for example, jpg,png. For details about all file name extensions supported by KooDrive, see Before You Start. A maximum of 100 extensions are supported.

Range:

N/A

Default Value:

N/A

categorys

No

String

Definition:

List of file types to be filtered.

Constraints:

This parameter is valid only for subfiles. The type elements are separated by commas (,), for example, 15,20. A maximum of 100 types are supported.

Range: 10: folder 15: image 20: video 26: word 27: excel 28: ppt 30: audio 35: compressed file 40: application 45: other

Default Value:

N/A

hidden

No

Boolean

Definition:

Whether it is hidden.

Constraints:

N/A

Range:

true: only hidden files are returned. false: only non-hidden files are returned.

Default Value:

Whether to hide files. By default, all files are returned.

isRecycled

No

Boolean

Definition:

Whether to collect statistics on files in the recycle bin.

Constraints:

N/A

Range:

If the value is true, only the usage of files deleted with the parent directory is collected. If the value of fileId is root, all files in the recycle bin are collected. If the value is false, only normal files in the recycle bin are collected. If the value is null or not transferred, when fileId is a recycle bin directory, the usage of files deleted with the parent directory is collected. When fileId is a normal directory, the usage of normal files is collected. When fileId is root, the usage of all files is collected.

Default Value:

null

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Traceid

No

String

Definition:

Service trace ID, which contains 58 bits.

Constraints:

N/A

Range:

The value contains 58 bits.

Default Value:

N/A

language

No

String

Definition:

Language code.

Constraints:

The value must comply with the internationalization specifications. For example, en_us indicates English (United States).

Range:

The value must comply with the internationalization specifications.

Default Value:

en-US

X-User-Id

Yes

String

Definition:

User ID on KooDrive, which is used for app authentication.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

X-Date

Yes

String

Definition:

Date, which is used for app authentication. The format is yyyyMMdd'T'HHmmss'Z'.

Constraints:

The time must be within 15 minutes from the current time and cannot be later than the current time.

Range:

N/A

Default Value:

N/A

x-hw-share-folder-id

No

String

Definition:

ID of the shared folder. If this request header is passed, the current operation is performed in the shared folder.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

Authorization

Yes

String

Definition:

Access token. Token authentication is used to call KooDrive APIs. A token indicates the permission. When an API is called, the token is added to the request header to obtain the operation permission. For details about how to obtain an access token, see the corresponding developer guide.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

code

String

Response code.

msg

String

Response information.

data

StatsData object

Data.

Table 4 StatsData

Parameter

Type

Description

totalSize

String

Total file size, in bytes.

subDirCount

String

Total number of subdirectories.

subFileCount

String

Total number of subfiles.

extensionStatistics

Map<String,DirStatistics>

Statistics result of the specified file name extension. Note: This parameter is returned only when extensionList is not empty. The value of subDircount in DirStatistics is empty.

categoryStatistics

Map<String,DirStatistics>

Statistical result of a specified file type. This parameter is returned only when categoryList is not empty. In DirStatistics, subDircount is valid only for directory files, and totalSize and subFileCount are valid only for common files.

Table 5 DirStatistics

Parameter

Type

Description

totalSize

String

Total file size.

subDirCount

String

Total number of subdirectories.

subFileCount

String

Total number of subfiles.

Example Requests

Query the number of directories, number of files, and total file size in directory FnNGsBnXUdIW7AycSK4ZCTIlPJ6JO1_sF.

POST /koodrive/ose/v1/files/statsDir?fileId=FnNGsBnXUdIW7AycSK4ZCTIlPJ6JO1_sF&containerId=IAAGvmhWei6Q7A4-A1557836058161393920&recursive=true

Authorization:Bearer+10f88*********4791e9ff

Example Responses

Status code: 200

Search results.

{
  "code" : 0,
  "msg" : "success",
  "data" : {
    "totalSize" : 0,
    "subDirCount" : 1,
    "subFileCount" : 0
  }
}

Status Codes

Status Code

Description

200

Search results.