Query file list¶
Lists files accessible to a connector. First get the file uri from the response and then preview the file.
GET https://moi.matrixorigin.cn/newmoi/connectors/files/list
Preparation before calling¶
Prepare the personal access token, target workspace ID, and connector ID that have access to the target workspace. Only connectors that support file enumeration can call this interface.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: The workspace ID to be queried, passed through theX-Workspace-IDHeader.$CONNECTOR_ID: The connector ID of the file to be enumerated, passed through theconnector_idquery parameter.
Request example¶
curl "https://moi.matrixorigin.cn/newmoi/connectors/files/list?connector_id=$CONNECTOR_ID&limit=20" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID"
Query parameters¶
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
The connector ID. |
|
string |
No |
The cursor returned from the previous page. |
|
integer |
No |
This page returns the quantity. The default value is |
|
string |
no |
Directory relative to the connector configuration root. |
|
integer[] |
No |
Filter only the file type codes of ordinary files. Pass this parameter repeatedly, for example |
[] after a type denotes an array. [] in a field path denotes each item in an array.
File type codes¶
file_types and response type use these codes:
Code |
Type |
Code |
Type |
|---|---|---|---|
|
Unrecognized |
|
TXT |
|
|
Generic image |
|
|
PPT |
|
Word |
|
Markdown |
|
CSV |
|
Parquet |
|
SQL |
|
Table of contents |
|
DOCX |
|
PPTX |
|
WAV |
|
MP3 |
|
AAC |
|
FLAC |
|
MP4 |
|
MOV |
|
MKV |
|
PNG |
|
JPG |
|
JPEG |
|
BMP |
|
XLS |
|
XLSX |
|
HTM |
|
HTML |
|
EML |
|
MSG |
|
P7S |
|
DWG |
|
DXF |
|
FAS |
|
DOC |
|
ZIP |
|
RAR |
|
7Z |
|
TAR |
|
TAR.GZ |
|
TAR.BZ2 |
|
GZ |
|
BZ2 |
limit is the amount used by the connector when reading a page. After applying file_types filter, the actual number of ordinary files returned by this page may be less than limit. Connectors that support cursor paging return the next page cursor when has_more is true; connectors that do not support paging return an empty cursor and has_more=false.
Successful response¶
Returns 200 on success.
{
"code": "OK",
"msg": "OK",
"data": {
"files": [
{
"uri": "/orders.csv",
"filename": "orders.csv",
"size": 1024,
"type": 1,
"path": "/",
"create_time": 0,
"update_time": 0
}
],
"cursor": "next_cursor",
"has_more": true
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
object[] |
Current page file; may be omitted or empty array when there is no file. |
|
string |
File URI, which can be used for subsequent previews. |
|
string |
File name. |
|
integer |
File size in bytes. |
|
integer |
File type code. |
|
string |
File path within the connector. |
|
integer |
The Unix timestamp of the file creation time. The current file list implementation returns |
|
integer |
Unix timestamp of when the file was updated. The current file list implementation returns |
|
string |
Next page cursor. Only used for next request if |
|
boolean |
Whether there is still a next page. |
In field paths, [] means each item in an array. For example, data.files[].uri is the uri field of each item in data.files.
Error response¶
{
"code": "ErrServer",
"msg": "server error",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The query parameter format is invalid. The response uses the |
Fix |
|
|
The connector does not exist, is not accessible, does not support enumerating files, or the service failed to read the file list. |
Check the connector ID and access permissions; verify that the connector supports file enumeration and try again. |
Follow-up operations¶
Save the uri and connector ID of the target file. When you need to confirm the file content, use these two values preview file.