Updated on 2025-12-02 GMT+08:00

Uploading an Image

Function

This API is used to upload images to the database.

URI

POST /v1/{project_id}/applications/{application_id}/uni-search/img/{img_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition:

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Constraints:

N/A

Value range:

The value can contain 1 to 64 characters. Only digits, letters, hyphens (-), and underscores (_) are allowed. The value must start with a letter.

Default value:

N/A

application_id

Yes

String

Definition:

Application ID. For details about how to obtain the application ID, see Obtaining an Application ID.

Constraints:

Character string

Value range:

The value can contain 1 to 64 characters. Only digits, letters, hyphens (-), and underscores (_) are allowed. The value must start with a letter.

Default value:

N/A

img_id

Yes

String

Definition:

Image ID.

Constraints:

The value must be a string of 32 letters and digits and must start with img-.

Value range:

N/A

Default value:

N/A

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

repo_id

No

String

Definition:

Knowledge base ID. When carried in the request, it specifies the target knowledge base for the query.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

file_id

No

String

Definition:

Document ID. When carried in the request, it specifies the source documents for the query.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition:

Token used for API authentication. For details about how to obtain the token, see Obtaining an IAM User Token.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

Table 4 FormData parameters

Parameter

Mandatory

Type

Description

image

Yes

File

Definition:

Uploaded image file.

Constraints:

The file must be in PNG, JPG, or JPEG format and cannot exceed 20 MB.

Value range:

N/A

Default value:

N/A

Response Parameters

Status code: 200

File uploaded successfully.

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Definition:

Error Code.

Value range:

N/A

error_msg

String

Definition:

Error message.

Value range:

N/A

Status code: 500

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Definition:

Error Code.

Value range:

N/A

error_msg

String

Definition:

Error message.

Value range:

N/A

Example Requests

  • Upload an image.

    /v1/b25446daeb1a41a7953c5deba2b2677a/applications/5071b12e-8c5c-4181-a15b-41e6ae3915ea/uni-search/img/img-00092484d4bf4582a7e3185f316e382b
    
    Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
    
    ----WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="image"; filename="/D:/output/1e653a704c9e4e2aaa95f13fbe7ec1e3.jpeg"
    Content-Type: image/jpeg
    
    (data)
    ----WebKitFormBoundary7MA4YWxkTrZu0gW
  • Upload image resources to a specified knowledge base and document.

    /v1/b25446daeb1a41a7953c5deba2b2677a/applications/5071b12e-8c5c-4181-a15b-41e6ae3915ea/uni-search/img/img-00092484d4bf4582a7e3185f316e382b?repo_id=604c3237-cc0c-43f4-a22d-727df38a9eb7&file_id=112da243b82cb4362136129717d15dfe
    
    Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
    
    ----WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="image"; filename="/D:/output/1e653a704c9e4e2aaa95f13fbe7ec1e3.jpeg"
    Content-Type: image/jpeg
    
    (data)
    ----WebKitFormBoundary7MA4YWxkTrZu0gW

Example Responses

None

Status Codes

Status Code

Description

200

File uploaded successfully.

400

Request error.

500

Internal error.

Error Codes

See Error Codes.