Help Center/ KooDrive/ API Reference/ API/ File Management/ Adding a File Directory
Updated on 2025-08-28 GMT+08:00

Adding a File Directory

Function

Add a file directory.

URI

POST /koodrive/ose/v1/directory

Request Parameters

Table 1 Request header parameters

Parameter

Mandatory

Type

Description

Authorization

Yes

String

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. The format is Bearer+{access_token}.

X-User-Id

Yes

String

User ID, which is used for app authentication.

X-Date

Yes

String

Date, which is used for app authentication.

Host

Yes

String

Address, which is used for app authentication.

X-Traceid

No

String

Message log trace ID. The value contains 58 bits.

language

No

String

Language code, which complies with the internationalization specifications. For example, en-US indicates English (United States). English (United States) is used by default.

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

createdTime

No

String

Time when the file is created.

Format: yyyy-MM-ddTHH:mm:ss.sssZ

description

No

String

File description. The value contains up to 512 characters and cannot contain invalid characters such as emojis.

mimeType

No

String

Resource type.

editedTime

No

String

File modification time.

fileName

Yes

String

File name. The value cannot contain the following characters: '<>|:"*? /', cannot be '..', '.', '', and can contain up to 250 characters.

fileType

Yes

String

File type, which is input externally.

The value is fixed at 10.

parentFolder

No

Array of strings

List of parent directory IDs. The first directory is used as the parent directory.

If this parameter is null, the file is created in the root directory.

containerId

Yes

String

Space ID.

renameMode

No

Integer

Duplicate name policy.

  • 2: Forcibly renames a file with an existing name by adding a timestamp to the end of the file name.

  • 3: Rejects files with the same name. A file with an existing name cannot be created.

hidden

No

Boolean

Whether the directory is hidden. (This function is available only to whitelisted users.)

smartFolderAttr

No

Array of SmartFolderAttr objects

Smart folder attributes. (This function is available only to whitelisted users.)

Table 3 SmartFolderAttr

Parameter

Mandatory

Type

Description

name

No

Integer

Attribute name.

type

No

Integer

Attribute type.

value

No

String

Attribute value.

sort

No

Integer

Sorting value.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

id

String

File ID.

fileName

String

File name.

mimeType

String

File format.

code

String

Response code.

msg

String

Response information.

Example Requests

Creates a folder in the root directory of the space IAADfsBFCO6WtAtuA315074383680425b8aa9a130cba2d4.

POST /koodrive/ose/v1/directory

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

{
    "createdTime": "",
    "editedTime": "",
    "description": "222",
    "mimeType": "application/vnd.huawei-apps.folder",
    "fileName": "ttgg",
    "fileType": "10",
    "parentFolder": [
        "root"
    ],
    "containerId": "IAADfsBFCO6WtAtuA315074383680425b8aa9a130cba2d4",
    "renameMode": "2"
}

Example Responses

Status code: 200

Information returned after the directory is created.

{
  "id" : "FqAHbpps7uJEDpvh2MbpLj7lD4AM2OWMR",
  "fileName" : "ttgg",
  "mimeType" : "application/vnd.huawei-apps.folder",
  "code" : 0,
  "msg" : "success"
}

Status Codes

Status Code

Description

200

Information returned after the directory is created.