列出空间首页内容

最近更新时间:2025-11-19 14:56:22

我的收藏

功能描述

用于列出空间首页内容,会忽略目录的层级关系,列出空间下所有文件。
说明:
需要 read_only、space_admin 或 admin 权限,有关权限详情请参见 生成访问令牌接口

请求

请求示例

GET /api/v1/space/`{LibraryId}`/`{SpaceId}`/contents-view?marker=`{Marker}`&limit=`{Limit}`&order_by=`{OrderBy}`&order_by_type=`{OrderByType}`&filter=`{DirectoryFilter}`&with_path=`{WithPath}`&access_token=`{AccessToken}`&user_id=`{UserId}`&category=`{Category}`

请求参数

请求参数
描述
类型
是否必选
LibraryId
媒体库 ID,在媒体托管控制台创建媒体库后获取,请参见 创建媒体库
String
SpaceId
空间 ID
如果媒体库为单租户模式,则该参数固定为连字符(-)
如果媒体库为多租户模式,则该参数为 创建租户空间 接口返回的空间 ID
String
Marker
用于顺序列出分页的标识,翻页时传入此参数
String
Limit
用于顺序列出分页时本地列出的项目数限制
Integer
OrderBy
排序字段,取值如下:
name:按名称排序(默认)
modificationTime:按修改时间排序
size:按文件大小排序
creationTime:按创建时间排序
uploadTime:按上传时间排序
localCreationTime:按照文件对应的本地创建时间排序
localModificationTime:按照文件对应的本地修改时间排序
String
OrderByType
排序方式,升序为 asc(默认),降序为 desc
String
Filter
筛选方式,onlyDir 只返回文件夹,onlyFile 只返回文件
String
Category
文件自定义的分类,最大长度16字节, 用户可通过更新文件接口修改文件的分类,也可以根据文件后缀预定义文件的分类信息
String
WithPath
是否返回 path,返回为 true,不返回为 false(默认)
Boolean
AccessToken
访问令牌,对于公有读媒体库或租户空间,可不指定该参数,否则必须指定该参数,获取请参见 生成访问令牌
String
UserId
用户身份识别,当访问令牌对应的权限为管理员权限且申请访问令牌时的用户身份识别为空时用来临时指定用户身份,详情请参见 生成访问令牌接口
String

请求体

响应

响应码

获取成功,返回 HTTP 200 OK。

响应体

application/json
响应体示例:
{
"nextMarker": "eyJ0eXBlIjoiZmlsZSIsIm5hbWUiOiJCTVcwLjMyNTE0NTE4ODkzMDYxNjk1LmpwZyJ9",
"contents": [
{
"name": "sub-dir1",
"path":["xxx","sub-dir1"],
"inode": "xxxx",
"type": "dir",
"creationTime": "2020-09-22T07:43:01.000Z",
"modificationTime": "2020-09-22T07:43:01.000Z",
"eTag": "0",
"category": "image",
"labels": ["动物", "大象", "亚洲象"]
},
{
"name": "sub-dir2",
"path":["xxx","sub-dir2"],
"inode": "xxxx",
"type": "dir",
"creationTime": "2020-09-22T07:43:14.000Z",
"modificationTime": "2020-09-22T07:43:14.000Z",
"eTag": "0",
"category": "dir",
"labels": ["动物", "大象", "亚洲象"]
},
{
"name": "file1.jpg",
"path":["xxx","file1.jpg"],
"type": "file",
"creationTime": "2020-09-22T07:44:45.000Z",
"modificationTime": "2020-09-22T07:44:45.000Z",
"versionId": 2,
"contentType": "image/jpg",
"size": "1048576",
"eTag": "xxx",
"crc64": "xxx",
"metaData": {
"x-smh-meta-foo": "bar"
},
"fileType": "powerpoint",
"previewByDoc": true,
"previewByCI": true,
"previewAsIcon": true,
"category": "image",
"labels": ["动物", "大象", "亚洲象"],
"localCreationTime": "2020-09-22T07:44:45.000Z",
"localModificationTime": "2020-09-22T07:44:45.000Z"
},
{
"name": "file2.docx",
"path":["xxx","file2.docx"],
"type": "file",
"creationTime": "2020-09-22T07:46:08.000Z",
"modificationTime": "2020-09-22T07:46:08.000Z",
"versionId": null,
"contentType": "application/vnd.openxmlformats-officedocument.wordprocessingm",
"size": "1048576",
"eTag": "xxx",
"crc64": "xxx",
"metaData": {
"x-smh-meta-foo": "bar"
},
"fileType": "powerpoint",
"previewByDoc": true,
"previewByCI": true,
"previewAsIcon": true,
"category": "jpg",
"labels": ["动物", "大象", "亚洲象"],
"localCreationTime": "2020-09-22T07:44:45.000Z",
"localModificationTime": "2020-09-22T07:44:45.000Z"
}
]
}
响应体字段说明:
响应参数
描述
类型
nextMarker
用于顺序列出分页的标识
String
contents
目录或相簿内的具体内容
Array
contents 中具体参数如下:
响应参数
描述
类型
name
目录或相簿名或文件名
String
path
表示文件的路径,仅当设置了withPath为true时返回该字段
String Array
inode
文件目录ID
String
versionId
版本号
Integer
type
条目类型,取值如下:
dir:目录或相簿
file:文件,仅用于文件类型媒体库
image:图片,仅用于媒体类型媒体库
video:视频,仅用于媒体类型媒体库
symlink:符号链接
String
creationTime
ISO 8601格式的日期与时间字符串,表示目录或相簿的创建时间或文件的上传时间,例如 2020-10-14T10:17:57.953Z
String
modificationTime
文件最近一次被覆盖的时间,或者目录内最近一次增删子目录或文件的时间
String
contentType
媒体类型(仅非目录或相簿返回)
String
size
文件大小,为了避免数字精度问题,这里为字符串格式(仅非目录或相簿返回)
String
eTag
子目录或文件的 eTag
String
crc64
文件的 CRC64-ECMA182校验值,为了避免数字精度问题,这里为字符串格式(仅非目录或相簿返回)
String
metaData
文件元数据信息(仅非目录或相簿返回)
Object
previewByDoc
是否可通过 wps 预览(仅非目录或相簿返回)
Boolean
previewByCI
是否可通过万象预览(仅非目录或相簿返回)
Boolean
previewAsIcon
是否可用预览图作为 icon(仅非目录或相簿返回)
Boolean
fileType
文件类型:excel、powerpoint 等(仅非目录或相簿返回)
String
labels
字符串数组,简易文件标签列表,跟 tagList 不同,此参数是通过上传、修改文件时指定的
String Array
category
文件自定义的分类(仅非目录或相簿返回)
String
localCreationTime
文件对应的本地创建时间(仅非目录或相簿返回)
String
localModificationTime
文件对应的本地修改时间(仅非目录或相簿返回)
String

错误码

该请求操作无特殊错误信息,常见的错误信息请参见 错误码 文档。

实际案例

案例一:列出空间中的目录

请求
GET /api/v1/space/smhxxx/spacexxx/contents-view?limit=5&filter=onlyDir&with_path=true&access_token=*** HTTP/1.1
Host: smhxxx.api.tencentsmh.cn
User-Agent: curl/8.5.0
Accept: */*

响应
HTTP/1.1 200 OK
Date: Wed, 12 Nov 2025 02:07:22 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 858
Server: nginx/1.29.0
X-Request-Id: 724cab56eac189c39811341d1fbb1314

{
"nextMarker": "",
"contents": [
{
"path": [
"photos",
"2024"
],
"name": "2024",
"inode": "04b035e3cf949e060006435190837196",
"type": "dir",
"creationTime": "2025-11-11T13:24:16.000Z",
"modificationTime": "2025-11-11T13:24:16.000Z",
"eTag": "1762867456000"
},
{
"path": [
"photos",
"2025"
],
"name": "2025",
"inode": "7f11a77fe8573d51000643519019697c",
"type": "dir",
"creationTime": "2025-11-11T13:24:09.000Z",
"modificationTime": "2025-11-11T13:24:09.000Z",
"eTag": "1762867449000"
},
{
"path": [
"documents"
],
"name": "documents",
"inode": "c6fbb4629d361627000643518f1384c9",
"type": "dir",
"creationTime": "2025-11-11T13:23:52.000Z",
"modificationTime": "2025-11-11T13:23:52.000Z",
"eTag": "1762867432000"
},
{
"path": [
"photos"
],
"name": "photos",
"inode": "0d5a750fd1567eff0006435190191034",
"type": "dir",
"creationTime": "2025-11-11T13:24:09.000Z",
"modificationTime": "2025-11-11T13:24:09.000Z",
"eTag": "1762867449000"
}
]
}

案例二:列出空间中的文件

请求
GET /api/v1/space/smhxxx/spacexxx/contents-view?limit=5&filter=onlyFile&with_path=true&access_token=*** HTTP/1.1
Host: smhxxx.api.tencentsmh.cn
User-Agent: curl/8.5.0
Accept: */*

响应
HTTP/1.1 200 OK
Date: Wed, 12 Nov 2025 02:10:27 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Server: nginx/1.29.0
X-Request-Id: 873a29bbbc19df14959fc1cc73a8a80b

{
"nextMarker": "CgooBTIEbmFtZUABEoEBCg52YWNhdGlvbi0yLmpwZxARGhMyMDI1LTExLTExIDIxOjI1OjQ1IhMyMDI1LTExLTExIDIxOjI1OjQ2KAFI0-MCYhMyMDI1LTExLTExIDIxOjI1OjQ2ahMxOTcwLTAxLTAxIDA4OjAwOjAwchMxOTcwLTAxLTAxIDA4OjAwOjAwGAE",
"contents": [
{
"path": [
"documents",
"document-A.txt"
],
"name": "document-A.txt",
"inode": "3bb74ab8cd515b750006435193924d28",
"type": "file",
"fileType": "text",
"category": "document",
"contentType": "text/plain",
"creationTime": "2025-11-11T13:25:08.000Z",
"modificationTime": "2025-11-11T13:25:08.000Z",
"eTag": "\\"9e3cc3ed21420c4ad53581c0155ce599\\"",
"size": "17",
"crc64": "6424280401416844775",
"previewByDoc": true,
"previewByCI": true,
"previewAsIcon": false,
"metaData": {},
"versionId": 1
},
{
"path": [
"documents",
"document-B.pdf"
],
"name": "document-B.pdf",
"inode": "7c2288076c0cb115000643519465209c",
"type": "file",
"fileType": "portable",
"category": "document",
"contentType": "application/pdf",
"creationTime": "2025-11-11T13:25:21.000Z",
"modificationTime": "2025-11-11T13:25:22.000Z",
"eTag": "\\"9e3cc3ed21420c4ad53581c0155ce599\\"",
"size": "17",
"crc64": "6424280401416844775",
"previewByDoc": true,
"previewByCI": true,
"previewAsIcon": false,
"metaData": {},
"versionId": 1
},
{
"path": [
"index.html"
],
"name": "index.html",
"inode": "e59dfdfc6a55f12b000643519282ee2b",
"type": "file",
"fileType": "text",
"category": "other",
"contentType": "text/html",
"creationTime": "2025-11-11T13:24:50.000Z",
"modificationTime": "2025-11-11T13:27:39.000Z",
"eTag": "\\"9e3cc3ed21420c4ad53581c0155ce599\\"",
"size": "17",
"crc64": "6424280401416844775",
"previewByDoc": true,
"previewByCI": true,
"previewAsIcon": false,
"metaData": {},
"versionId": 1
},
{
"path": [
"photos",
"2025",
"vacation-1.jpg"
],
"name": "vacation-1.jpg",
"inode": "051b7052998292fe000643519543fbff",
"type": "file",
"fileType": "image",
"category": "image",
"contentType": "image/jpeg",
"creationTime": "2025-11-11T13:25:36.000Z",
"modificationTime": "2025-11-11T13:25:36.000Z",
"eTag": "\\"9e3cc3ed21420c4ad53581c0155ce599\\"",
"size": "17",
"crc64": "6424280401416844775",
"previewByDoc": false,
"previewByCI": true,
"previewAsIcon": true,
"metaData": {},
"versionId": 1
},
{
"path": [
"photos",
"2024",
"vacation-1.jpg"
],
"name": "vacation-1.jpg",
"inode": "ab85b55db58caedb0006435197c512c5",
"type": "file",
"fileType": "image",
"category": "image",
"contentType": "image/jpeg",
"creationTime": "2025-11-11T13:26:18.000Z",
"modificationTime": "2025-11-11T13:26:18.000Z",
"eTag": "\\"9e3cc3ed21420c4ad53581c0155ce599\\"",
"size": "17",
"crc64": "6424280401416844775",
"previewByDoc": false,
"previewByCI": true,
"previewAsIcon": true,
"metaData": {},
"versionId": 1
}
]
}