AddFile

更新时间:
复制 MD 格式

Imports a file from the temporary storage space of Alibaba Cloud Model Studio into a data connection (formerly known as application data).

Operation description

  • To call this API, a RAM user (sub-account) must have the required API permissions for Alibaba Cloud Model Studio and be added to a workspace. The required policy is AliyunBailianDataFullAccess, which includes the sfm:AddFile permission. An Alibaba Cloud account (primary account) can call this API directly without authorization. We recommend using the latest Alibaba Cloud Model Studio SDK to call this API.

  • This API is not idempotent.

Throttling: Frequent calls to this API are subject to throttling. Do not exceed a rate of 10 calls per second. If your request is throttled, try again later.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

sfm:AddFile

create

*All Resource

*

None None

Request syntax

PUT /{WorkspaceId}/datacenter/file HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

WorkspaceId

string

Yes

The ID of the workspace where you want to upload the file. For information about how to obtain the workspace ID, see How to use workspaces.

llm-3shx2gu255oqxxxx

Request parameters

Parameter

Type

Required

Description

Example

LeaseId

string

Yes

The upload lease ID. This value maps to the FileUploadLeaseId returned by the ApplyFileUploadLease API.

68abd1dea7b6404d8f7d7b9f7fbd332d.17166xxxxxxxx

Parser

string

Yes

The type of parser. Valid values:

  • DOCMIND: Intelligent Document Parsing

  • DOCMIND_DIGITAL: Digital Document Parsing

  • DOCMIND_LLM_VERSION: Large Language Model-based Document Parsing

  • DASH_QWEN_VL_PARSER: Qwen-VL Parsing

  • DOCMIND_LLM_VERSION_MEDIA: Audio and Video Parsing

  • AUTO_SELECT: Automatic Parser Selection

Note If CategoryType is set to UNSTRUCTURED, the parser parses your uploaded file based on the category’s data parsing settings.
Note If CategoryType is set to SESSION_FILE, the system uses a default parsing method that cannot be changed.

AUTO_SELECT

CategoryId

string

Yes

  • If CategoryType is set to UNSTRUCTURED, you must specify the ID of the category to which the file belongs. This is the CategoryId returned by the AddCategory API. You can also obtain the category ID by navigating to the **Application data** > **Files** tab and clicking the ID icon next to the category name. You can specify default to use the default category.

  • If CategoryType is set to SESSION_FILE, specify default.

cate_cdd11b1b79a74e8bbd675c356a91ee35xxxxxxxx

Tags

array

No

  • A list of tags for the file. You can specify up to 100 tags. The total length of all tags cannot exceed 700 characters.

  • If this parameter is not specified, no tags are added.

string

No

A tag for the file. Each tag can be up to 32 characters long and can contain Unicode letters (including English letters, Chinese characters, and digits), underscores (_), and hyphens (-).

产品介绍

CategoryType

string

No

The type of category. This parameter is optional. Default value: UNSTRUCTURED. Valid values:

  • UNSTRUCTURED: A category used for building a knowledge base.

  • SESSION_FILE: A file used for interactions within an agent session.

    Note If you set this parameter to SESSION_FILE, you must also set the CategoryType parameter to SESSION_FILE when you call the ApplyFileUploadLease API.
    Note Files of this type are valid only for the current session and expire after the session is closed, with a maximum validity of 7 days. These files are not intended for long-term storage.

UNSTRUCTURED

OriginalFileUrl

string

No

The URL of the file. The system records this link when building a document retrieval-based knowledge base. When you interact with an agent in the Alibaba Cloud Model Studio console, this URL is returned with the retrieval results for the file in the docUrl field.

Note

For this parameter to take effect, the knowledge base feature must be enabled for the agent, and the display the source of the answer option must be enabled.

www.test.com/111.docx

ParserConfig

object

No

The parser configuration. This parameter is required only if you set Parser to DASH_QWEN_VL_PARSER.

ModelName

string

No

The model name.

qwen-vl-max

ModelPrompt

string

No

The prompt to use when calling the Qwen-VL parser.

#角色 你是一个专业的图片内容标注人员,擅长识别并描述出图片中的内容。 # 任务目标 请结合输入图片,详细描述图片中的内容。

Response elements

Element

Type

Description

Example

object

The response object.

Code

string

The error code.

DataCenter.FileTooLarge

Data

object

The data returned for the request.

FileId

string

The ID of the file. Save this ID for use in subsequent API calls involving this file.

file_9a65732555b54d5ea10796ca5742ba22_xxxxxxxx

Parser

string

The parser that was used for the file. A possible value is:

  • DASHSCOPE_DOCMIND: Alibaba Cloud Document Intelligence

DASHSCOPE_DOCMIND

Message

string

The error message.

User not authorized to operate on the specified resource.

RequestId

string

The request ID.

778C0B3B-xxxx-5FC1-A947-36EDD13606AB

Status

string

The status code of the request.

200

Success

string

Indicates whether the API call was successful. Valid values:

  • true: The call was successful.

  • false: The call failed.

true

Examples

Success response

JSON format

{
  "Code": "DataCenter.FileTooLarge",
  "Data": {
    "FileId": "file_9a65732555b54d5ea10796ca5742ba22_xxxxxxxx",
    "Parser": "DASHSCOPE_DOCMIND"
  },
  "Message": "User not authorized to operate on the specified resource.",
  "RequestId": "778C0B3B-xxxx-5FC1-A947-36EDD13606AB",
  "Status": "200",
  "Success": "true"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.