Help Center/ KooDrive/ API Reference/ API/ File Management/ Adding a File Directory
Updated on 2024-07-30 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-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.

Maximum: 512

mimeType

No

String

Resource type.

editedTime

No

String

File modification time.

fileName

Yes

String

File name. The value cannot contain <>|:"*? /. The value cannot be two periods (..), a period (.), or a space.

Maximum: 80

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. container, parentAlias, and parentFolder are mutually exclusive. parentFolder is preferred.

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.

Response Parameters

Status code: 200

Table 3 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.