tencent cloud

Search Directory and File
Last updated: 2026-01-07 14:28:01
Search Directory and File
Last updated: 2026-01-07 14:28:01

Description

Search directory and file.
Note:
When this interface is used to initiate an asynchronous search task, the interface will return in approximately 2s. If partial or full search results are available at the time of return, the first page of the found results will be returned (20 per page). If no results are found yet, an empty array will be returned. Therefore, the actual number of contents returned by this interface may range from 0 to 20. To determine whether there are more search results, refer to the hasMore field instead of the number of contents.
When subsequent pages need to be fetched, use the Continue Fetching Search Results interface.

Request

Request Example

POST /api/v1/search/{LibraryId}/{SpaceId}/space-contents?access_token={AccessToken}&user_id={UserId}

Request Parameter

Request parameters.
Description
Type
Required or Not
LibraryId
Media Library ID, obtain it after creating a media library in the media hosting console, see create media library
String
Yes
SpaceId
Space ID, you must specify this parameter. If the media library is in single-tenant mode, this parameter is fixed as hyphen (-)
String
No
AccessToken
Access token, see Generate Access Token
String
Yes
UserId
User identity recognition. When the permission corresponding to the access token is administrator permission and the user identity recognition during access token application is empty, it is used to temporarily specify user identity. For details, see Generate Access Token API.
String
No

Request Body

application/json, specified search conditions.
Request body example:
{
"keyword": "ID card",
"scope": "personal file/document",
"type": "image",
"extname": [".png", ".jpg"],
"minFileSize": 1024,
"maxFileSize": 2048,
"modificationTimeStart": "2022-07-26T02:58:09.000Z",
"modificationTimeEnd": "2022-07-26T02:58:19.000Z",
"orderBy": "name",
"orderByType": "asc", // asc/desc
"searchMode": "fast", // fast/normal
"labels": ["elephant"],
"categories ": ["zip"]
}
Request body field description:
Request parameters.
Description
Type
Required or Not
keyword
Search keywords. Use spaces to separate multiple keywords. Keywords have an "OR" relationship, with priority display for projects matching more keywords.
String
Yes
scope
Search scope, specify the directory to search. For example, to search the root directory, you can specify an empty string, "/", or leave this field unspecified.
String
No
extname
Search for file extensions
String Array
Yes
type
Search type, optional parameter, string or string array, with negation support (!). Currently supported types include:
all: Search all types of files and folders. Defaults to all when type is not specified or empty. Use !all to exclude.
dir: Search directories only, excluding files. Use !dir to exclude.
file: Search files only, excluding directories. Use !file to exclude.
doc, xls, or ppt: Search Word, Excel, or Powerpoint documents only, with corresponding file extensions .doc(x), .xls(x), or .ppt(x). Use !doc, !xls, or !ppt to exclude.
pdf or txt: Search PDF or plain text documents only, with file extensions .pdf or .txt. Use !pdf or !txt to exclude.
image, video, or audio: Search image, video, or audio files only, with corresponding MIME (Content Type) as image/*, video/*, or audio/*. Use !image, !video, or !audio to exclude.
powerpoint: Search presentation files only, such as .ppt, .pptx, .pot, .potx. Use !powerpoint to exclude.
excel: Search spreadsheet files only, such as .xls, .xlsx, .ett, .xltx, .csv. Use !excel to exclude.
word: Search document files only, such as .doc, .docx, .dot, .wps, .wpt. Use !word to exclude.
text: Search plain text files only, such as .txt, .asp, .htm. Use !text to exclude.
String/String Array
No
minFileSize/maxFileSize
Search file size range, unit Byte
Int
No
modificationTimeStart/modificationTimeEnd
Search update time range, irrelevant to time zone
String
No
orderBy
Sorting field, currently supported by name, last modified, file size, creation time. Specific types are as follows:
name: sort by name
modificationTime: sort by modification time
size: sort by file size
creationTime: sort by creation time
localCreationTime: sort by local creation time
localModificationTime: sort by local last modified
String
No
orderByType
Sorting method, ascending as asc, descending as desc
String
No
searchMode
Search method, fast as fast, normal as normal, default normal
String
No
labels
Simplified file tag
String Array
No
categories
File custom category info
String Array
No

Response

Response code

Search successful, back HTTP 200 OK.

Response Body

application/json
Response body example:
{
"searchId": "FnMwV3NweXJOU2hTOTRpTnF0TW9EZVEeVUFhYUl5TGFSaTZtZUpDcEpUcEtxdzo3NjQ3NjU1",
"searchFinished": true,
"hasMore": true,
"nextMarker": 20,
"contents": [
{
"type": "file",
"inode": "xxxx",
"name": "api.zip",
"creationTime": "2021-08-19T04:40:01.000Z",
"modificationTime": "2021-08-19T04:40:01.000Z",
"contentType": "application/zip",
"size": "67084",
"eTag": "\\"52c2d19d61fae57d11caabe87f71de73\\"",
"isFavorite": true,
"crc64": "8970780629994048831",
"versionId":2,
"metaData": {
"x-smh-meta-creation-date": "Thu, 19 Aug 2021 04:39:59 GMT"
},
"path": ["api.zip"],
"userId": "12",
"localCreationTime": "2020-09-22T07:44:45.000Z",
"localModificationTime": "2020-09-22T07:44:45.000Z",
"authorityList": {
"canView": true,
"canPreview": true,
"canDownload": true,
"canPrint": true,
"canUpload": true,
"canDelete": true,
"canModify": true,
"canAuthorize": true,
"canShare": true,
"canPreviewSelf": true,
"canDownloadSelf": true
},
"authorityButtonList": {
"showViewButton": true,
"showPreviewButton": true,
"showDownloadButton": true,
"showUploadButton": true,
"showDeleteButton": true,
"showAuthorizeButton": true,
"showShareButton": true,
"showModifyButton": true,
"showMoveButton": true,
"showRenameButton": true,
"showCopyButton": true,
"showRestoreButton": true
}
},
{
"type": "file",
"inode": "xxxx",
"name": "bmw (1).PDF",
"creationTime": "2021-08-21T07:56:32.000Z",
"modificationTime": "2021-08-21T07:56:32.000Z",
"contentType": "application/pdf",
"size": "241674",
"eTag": "\\"030ca96f0af3b3d3cfbf31c2be3129d6\\"",
"isFavorite": false,
"crc64": "12098979488941977387",
"metaData": {
"x-smh-meta-creation-date": "Sat, 21 Aug 2021 07:56:30 GMT"
},
"path": ["abc", "bmw (1).PDF"],
"userId": "12",
"localCreationTime": "2020-09-22T07:44:45.000Z",
"localModificationTime": "2020-09-22T07:44:45.000Z"
},
{
"type": "file",
"inode": "xxxx1",
"name": "bmw.pdf",
"creationTime": "2021-08-17T13:19:07.000Z",
"modificationTime": "2021-08-17T13:19:07.000Z",
"contentType": "application/pdf",
"size": "241674",
"eTag": "\\"030ca96f0af3b3d3cfbf31c2be3129d6\\"",
"isFavorite": false,
"crc64": "12098979488941977387",
"metaData": {
"x-smh-meta-creation-date": "Tue, 17 Aug 2021 13:19:06 GMT"
},
"path": ["abc", "bmw.pdf"],
"userId": "12",
"localCreationTime": "2020-09-22T07:44:45.000Z",
"localModificationTime": "2020-09-22T07:44:45.000Z"
},
{
"type": "dir",
"inode": "xxx999",
"name": "fysn",
"creationTime": "2021-08-20T10:01:40.000Z",
"modificationTime": "2021-08-21T07:30:25.000Z",
"path": ["fysn"],
"userId": "12",
"isFavorite": false
},
{
"type": "file",
"inode": "xxbb",
"name": "Smart Media Hosting-144px (1).png",
"creationTime": "2021-08-20T09:59:25.000Z",
"modificationTime": "2021-08-20T09:59:25.000Z",
"contentType": "image/png",
"size": "7199",
"eTag": "\\"7d9ce6ef46c00d3924702b7b4224d029\\"",
"isFavorite": true,
"crc64": "13076174829147183381",
"metaData": {
"x-smh-meta-creation-date": "Fri, 20 Aug 2021 09:59:22 GMT"
},
"path": ["fysn", "Smart Media Hosting-144px (1).png"],
"previewByDoc": true,
"previewByCI": true,
"previewAsIcon": true,
"fileType": "powerpoint",
"userId": "12",
"localCreationTime": "2020-09-22T07:44:45.000Z",
"localModificationTime": "2020-09-22T07:44:45.000Z"
}
/* ... */
]
}
Response body field description:
Response Parameters
Description
Type
searchId
Search task ID for asynchronously fetching search result
String
searchFinished
Whether the search has been completed
Boolean
hasMore
Whether there are more search results
Boolean
nextMarker
Pagination identifier for obtaining subsequent pages, this field is returned only when hasMore is true
Int
contents
Page 1 search result may be an empty array. For async search details, see [API description].
Int
The contents include the following:
Response Parameters
Description
Type
type
Entry type, supports the following types:
dir: directory or album;
file: file, only used for file type media library;
image: image, only used for media type media library;
video: video, only used for media type media library;
symlink: symbolic link;
String
inode
File directory ID
String
name
Directory or album name or file name
Boolean
creationTime
Date and time string in ISO 8601 format, representing the creation time of a directory or album or the upload time of a file, for example: 2020-10-14T10:17:57.953Z
String
modificationTime
The time when the file was last overwritten, or the last time a subdirectory or file was added or removed in the directory
String
contentType
Media type
String
versionId
Version number.
String
size
File size, in string format to avoid digit precision issues.
String
isFavorite
boolean value, whether it is a favorite, returns when WithFavoriteStatus = 1
Boolean
eTag
File ETag
String
crc64
File CRC64-ECMA182 check value, in string format to avoid digit precision issues.
String
metaData
file metadata information
Object
path
The directory where the current project is located, containing the project name
String
userId
Creator/Updater User ID
String
previewByDoc
whether wps can preview
Boolean
previewByCI
whether Wanxiang can preview
Boolean
previewAsIcon
whether the preview image can be used as an icon
Boolean
fileType
File type: excel, powerpoint, etc.
String
labels
Simplified file tag
String Array
category
Custom file categories, such as image, video, doc
String
localCreationTime
Local file creation time
String
localModificationTime
Local file modification time
String
sensitiveWordAuditStatus
Sensitive text review status, including online and offline statuses: 0, 1.
0: not enabled
1: enable
Int
spaceId
space id
String
userOrgId
User original id
String
spaceTag
space tag
String
modifierName
Modifier name
String
highlight
emphasize
String
authorityList
Permission list
Array
authorityButtonList
Button permission list
Array
The authorityList contains the following parameters:
Response Parameters
Description
Type
canView
whether it can be viewed
Boolean
canPreview
whether it can be previewed
Boolean
canDownload
whether it can be downloaded
Boolean
canPrint
whether it can be printed
Boolean
canUpload
whether it can be uploaded
Boolean
canDelete
Deletable or Not
Boolean
canModify
whether it is editable
Boolean
canAuthorize
whether it can be authorized
Boolean
canShare
Share or not
Boolean
canPreviewSelf
whether it can be previewed
Boolean
canDownloadSelf
whether it can be downloaded
Boolean
The authorityButtonList contains the following parameters:
Response Parameters
Description
Type
showViewButton
Display the view button
Boolean
showPreviewButton
Display the preview button
Boolean
showDownloadButton
Display the download button
Boolean
showUploadButton
Display the upload button
Boolean
showDeleteButton
Display the delete button
Boolean
showAuthorizeButton
Display the authorization button
Boolean
showShareButton
Display the share button
Boolean
showModifyButton
Display the edit button
Boolean
showMoveButton
Display the mobile button
Boolean
showRenameButton
Display the rename button
Boolean
showCopyButton
Display the copy button
Boolean
showRestoreButton
Display the recovery button
Boolean

Error Codes

This request operation has no special error messages. For common error messages, see Error Codes.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback