Preview file

Read the preview contents of a temporary file or file within a connector.

HTTP
POST $CLOUDSIGMA_API_BASE/connectors/file/preview

Before you call

Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. Prepare personal access token and target workspace ID that can access the target workspace. The temporary file is obtained from Upload connector file. The files within the connector obtain the connector ID and file URI from Query connector file list.

Request body

Replace $CLOUDSIGMA_API_KEY, $WORKSPACE_ID, $CONN_FILE_ID in the example with actual values.

Shell
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\": 2,
    \"columnNameRow\": 1,
    \"isColumnName\": true
  }"

Field

Type

Required

Description

connector_id

string

No

The ID of the saved connector.

uri

string

No

The URI of the file within the connector.

conn_file_id

string

No

Temporary file ID to preview.

sheet_name

string

No

The name of the worksheet to be read.

isColumnName

boolean

No

Whether to use a column-name row.

rowStart

integer

No

The starting row of preview data.

columnNameRow

integer

No

Row number as column name.

csv

object or null

No

CSV parsing configuration.

csv.separator

string

When the object is provided

Field separator.

csv.delimiter

string

When the object is provided

The delimiter used to reference the field.

csv.isEscape

boolean

When the object is provided

Whether backslash escaping is enabled.

file_type

integer

No

File type code used for parsing. A value greater than 0 overrides the automatically detected type.

CSV character configuration only takes the first byte and does not support multi-byte delimiter characters. When delimiter is empty, quote processing is turned off.

columnValues may be null, and sheets will not be returned when it is empty. The preview results may contain 21 records, but the maximum number is not guaranteed to be 20.

Successful response

JSON
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "conn_file_id": "conn_file_01",
    "file_type": 25,
    "rows": [
      {
        "number": 1,
        "columnName": "id",
        "columnValues": [
          "1",
          "2"
        ],
        "charNumber": "",
        "charColumnName": ""
      }
    ],
    "sheets": [
      {
        "name": "Sheet1",
        "row_count": 2
      }
    ]
  }
}

Field

Type

Description

data.conn_file_id

string

Temporary file ID used for this preview.

data.file_type

integer

The actual file type code used for previewing.

data.rows

array of object

Preview data organized by columns.

data.rows[].number

integer

number.

data.rows[].columnName

string

Column name.

data.rows[].columnValues

array of string or null

List of column values.

data.rows[].charNumber

string

Display number.

data.rows[].charColumnName

string

Display column names.

data.sheets

array of object

Spreadsheet worksheet.

data.sheets[].name

string

Name.

data.sheets[].row_count

integer

Number of rows.

Error response

JSON
{
  "code": "ErrIAMRequestInvalid",
  "msg": "invalid parameter"
}

Field

Type

Description

code

string

error code.

msg

string

error message.

Last updated on