Preview file¶
Read the preview contents of a connector file or temporary file. You can upload local files first, or query the file list in the connector first.
POST $CLOUDSIGMA_API_BASE/connectors/file/preview
Before you call this API¶
Configure the regional API endpoint and authentication, and select the target workspace.
Reading connector files requires usage rights for the connector.
Set the operation-specific values used in the request:
$CONN_FILE_ID: The temporary file ID returned after uploading the file, passed throughconn_file_id.$CONNECTOR_IDand$FILE_URI: The connector ID and fileuriobtained after querying the connector file list, passed throughconnector_idanduri.
Request¶
Preview the temporary file just uploaded:
curl -X POST "$CLOUDSIGMA_API_BASE/connectors/file/preview" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{
\"conn_file_id\": \"$CONN_FILE_ID\",
\"rowStart\": 1,
\"isColumnName\": true
}"
curl -X POST "$CLOUDSIGMA_API_BASE/connectors/file/preview" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{
\"connector_id\": \"$CONNECTOR_ID\",
\"uri\": \"$FILE_URI\",
\"rowStart\": 1,
\"isColumnName\": true
}"
Preview files in a saved connector:
Request body
Field |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Required |
Temporary file ID. This field will be used first when it is not empty. |
|
string or integer |
Required |
Connector ID. Only used when |
|
string |
Required |
Connector file URI. Only used when |
|
string |
No |
The sheet name of the XLS or XLSX file. |
|
integer |
No |
The starting row of preview data; if |
|
integer |
No |
The row number used as the column name; only used when |
|
boolean |
No |
Whether to use the row specified by |
|
integer |
no |
File type code. Greater than |
|
object |
No |
CSV parsing configuration. Use commas to separate and double quotes when omitted. |
|
string |
No |
Field separator, using the first byte of the string. |
|
string |
No |
Field wrapper, using the first byte of the string; no wrapper is used when omitted. |
|
boolean |
No |
Whether to use backslash as the escape character for the wrapper. |
[] after a type denotes an array. [] in a field path denotes each item in an array.
The request must provide a valid conn_file_id, or both connector_id and uri if conn_file_id is empty.
Successful response¶
Returns 200 on success.
{
"code": "OK",
"msg": "OK",
"data": {
"conn_file_id": "conn_file_01",
"file_type": 1,
"rows": [
{
"number": 1,
"columnName": "id",
"columnValues": ["1", "2"],
"charNumber": "1",
"charColumnName": "A"
}
],
"sheets": [
{
"name": "Sheet1",
"row_count": 2
}
]
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
string |
ID of the temporary file being previewed. When using connector file preview, this ID is returned after the content is saved as a temporary file; available for download or deletion. |
|
integer |
File type code. |
|
object[] |
Preview rows. |
|
integer |
Row number. |
|
string |
Column name. |
|
string[] |
Preview values for the column. |
|
string |
Character position identifier. |
|
string |
Column name for the character position. |
|
object[] |
Spreadsheet sheet; may be omitted for other file types. |
|
string |
Worksheet name. |
|
integer |
Worksheet row count. |
In field paths, [] means each item in an array. For example, items[].name is the name field of each item in items.
Error response¶
{
"code": "ErrNotFound",
"msg": "file not found",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The JSON request body cannot be parsed. The response uses the |
Check JSON type and format and try again. |
|
|
The temporary file or connector file does not exist. |
Query the file again and confirm the file ID or URI. |
|
|
The file location field was not provided, or the service failed to read, save, or parse the file. |
Pass in a valid file location field; check the file format and try again. |
Follow-up operations¶
After confirming that the preview rows and worksheet are as expected, if the response returns a temporary file ID, use that ID Create Task. When you need to get the file content, use this ID download file.