Help Center/ KooDrive/ API Reference/ API/ File Management/ Retrieving Files Using Search Engine Capabilities
Updated on 2024-07-30 GMT+08:00

Retrieving Files Using Search Engine Capabilities

Function

Search for files in a space by conditions such as search scope, parent directory, file name, file size range, update time range, and owner. Common users and department administrators can search for their individual and team space. Tenant administrators can search for all team spaces of the tenant.

URI

POST /koodrive/ose/v1/files/search

Request Parameters

Table 1 Request header parameters

Parameter

Mandatory

Type

Description

X-Traceid

No

String

Message log trace ID. The value contains 58 bits.

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}.

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

searchType

Yes

String

Query type, which is the individual space or team space.

pageInfo

Yes

pageInfo object

Pagination information.

filter

No

filter object

Filter.

sortInfo

No

sortInfo object

Sorting information.

recycled

No

Boolean

Whether files in the recycle bin are queried.

  • true: Queries files in the recycle bin.

  • false: Queries other files in the space.

Default: false

recursived

No

Boolean

Whether files in sub-directories are queried recursively. Default value: false.

Table 3 pageInfo

Parameter

Mandatory

Type

Description

pageSize

Yes

Integer

Number of records on each page.

Minimum: 1

Maximum: 100

pageCursor

Yes

String

Start cursor. If this parameter is null, the query starts from the first page.

Table 4 filter

Parameter

Mandatory

Type

Description

keyWord

No

String

File name, which is used for fuzzy match.

Minimum: 1

Maximum: 255

containerId

No

String

Space ID. This parameter is mandatory when the parent directory is specified.

parentFolder

No

String

Parent directory.

fileType

No

String

File type. Enumerated values: /** * Folder / FOLDER("10"), /* * Image / PICTURE("15"), /* * Video / VIDEO("20"), /* * Word file / WORD("26"), /* * Excel file / EXCEL("27"), /* * PowerPoint file / PPT("28"), /* * Audio / AUDIO("30"), /* * Compressed file / ARCHIVE("35"), /* * Application / APPLICATION("40"), /* * Other */ OTHER("45");

updateTimeRange

No

String

Update time range.

ownerId

No

String

File owner.

Table 5 sortInfo

Parameter

Mandatory

Type

Description

sortType

No

String

Enumerated values:

  • fileName: file name.

  • size: file size. -** type**: file format.

  • updateTime: update time.

  • createTime: creation time.

  • recycledTime: deletion time.

  • fileSuffix: file sub-category.

sortDirection

No

String

Enumerated values:

  • desc: descending order.

  • asc: ascending order.

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

code

Integer

Response code. 0 indicates success. Other values indicate failure.

msg

String

Success and error information.

files

Array of files objects

Search results

total

Integer

Total number of records.

nextPageCursor

String

Start cursor of the next page. It is null for the last page.

Table 7 files

Parameter

Type

Description

id

String

File ID.

fileSuffix

String

File suffix.

fileName

String

File name.

fileType

String

File type.

size

String

File size.

updateTime

String

Update time.

namePath

String

Full name path.

idPath

String

Full ID path.

downloadLinks

Array of DownLoadLink objects

Thumbnail link, which is returned for an image.

teamName

String

Department name or group space name returned for the team space.

teamId

String

Group ID, that is, department ID or group ID.

containerId

String

Space ID.

containerType

String

0: department space; 1: individual space; 2: group space.

favorite

Boolean

Whether the file returned by the individual space or team space is added to favorites by the current user.

owner

String

Owner name returned for the team space.

metadataAuditInfo

FileAuditInfo object

File moderation information.

contentAuditInfo

FileAuditInfo object

File moderation information.

Table 9 FileAuditInfo

Parameter

Type

Description

auditStatus

Integer

Moderation status.

  • 0: not reviewed.

  • 1: reviewed.

Enumeration values:

  • 0

  • 1

auditLevel

Integer

Moderation level.

  • 10: machine moderation.

  • 20: human moderation.

  • 30: machine and human moderation.

  • 99: appeal moderation.

Enumeration values:

  • 10

  • 20

  • 30

  • 99

auditResult

Integer

Moderation result.

  • 1: normal file.

  • 2: file with low-sensitive content.

  • 3: file with high-sensitive content.

  • 4: file with sensitive metadata.

Enumeration values:

  • 1

  • 2

  • 3

  • 4

auditDetail

String

Moderation details.

Example Requests

Example request for searching for a file.

POST /koodrive/ose/v1/files/search

Authorization:Bearer+10f88*********4791e9ff
{
  "searchType" : " personal/team",
  "pageInfo" : {
    "pageSize" : 100,
    "pageCursor" : 1
  },
  "filter" : {
    "keyWord" : "Material",
    "containerId" : "123456",
    "parentFolder" : "1",
    "fileType" : "1",
    "sizeRang" : "1024,2048",
    "updateTimeRange" : "2023-11-02,2023-11-21",
    "ownerId" : "Owner ID"
  }
}

Example Responses

Status code: 200

Search results

{
  "code" : 0,
  "msg" : "success",
  "files" : [ {
    "id" : "Abc",
    "fileName" : "Abc",
    "fileType" : "1",
    "size" : "1024",
    "updateTime" : "2023-05-26T02:08:53.683Z",
    "namePath" : "",
    "downloadLinks" : "",
    "deptName" : ""
  } ],
  "total" : 1000
}

Status Codes

Status Code

Description

200

Search results