Imports files from an authorized OSS bucket into Alibaba Cloud Model Studio application data.
Operation description
-
Make sure the OSS bucket belongs to the same Alibaba Cloud account as Model Studio and that authorization has been completed as described in Importing data from OSS configuration instructions.
- Supported bucket storage types do not include Archive, Cold Archive, or Deep Cold Archive. Buckets with content encryption enabled are supported. Buckets with public read/write, public read, or private access are supported.
- To use a bucket with Referer-based hotlink protection enabled, add the domain name
*.console.aliyun.comto the Referer whitelist as described in Allow access only from trusted websites.
-
Resource Access Management (RAM) users must first obtain API permissions for Model Studio (the
AliyunBailianDataFullAccesspermission is required, which includes the sfm:AddFilesFromAuthorizedOss permission) and join a workspace before invoking this operation. Alibaba Cloud accounts can invoke this operation directly without authorization. Call this operation by using the latest Model Studio SDK. - This operation does not have idempotence.
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
Actionelement 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
Resourceelement of the policy. - For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the
Resourceelement of the policy.
- For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the
- 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:AddFilesFromAuthorizedOss | create | *All Resource
| None | None |
Request syntax
Path Parameters
Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| WorkspaceId | string | Yes | The workspace ID. Files are imported into this workspace. For more information about how to obtain the workspace ID, see How to use a workspace. | llm-3z7uw7fwz0vxxxx |
Request parameters
Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| CategoryId | string | Yes | The ID of the category to which the files are imported. This is the | cate_cdd11b1b79a74e8bbd675c356a91ee35xxxxxxxx |
| CategoryType | string | Yes | The category type. Optional. Default value: UNSTRUCTURED. Valid values:
Valid values:
| UNSTRUCTURED |
| OssRegionId | string | Yes | The region ID of the OSS bucket. For more information, see OSS regions and endpoints. | cn-beijing |
| OssBucketName | string | Yes | The name of the OSS bucket. For more information, see Buckets. | bucketNamexxxxx |
| FileDetails | array<object> | Yes | The list of files to import. A maximum of 10 files can be uploaded at a time. A maximum of 10 files can be uploaded at a time. | |
array<object> | Yes | The file object. | ||
| FileName | string | Yes | The name of the file to import. The file name must include the file format extension.
If the name of the imported file is the same as an existing file in the knowledge base, the operation still returns a Status of SUCCESS, but the file is not actually imported. The existing file with the same name remains unchanged. Make sure that each imported file name is unique.To create a data table and upload data, use the Model Studio console. This is not supported through the API. | this_is_temp_xxxx.pdf |
| OssKey | string | Yes | The key of the file in the OSS bucket. For more information, see Object naming conventions. | root/path/this_is_temp_xxxx.pdf |
| Parser | string | No | The parser type. Valid values:
The uploaded file is parsed by using the specified parser. If you set this parameter to AUTO_SELECT, the parser configured for the category is used. | AUTO_SELECT |
| ParserConfig | object | No | The parser configuration. This parameter is required only when the parser type is set to Qwen VL parsing. | |
| ModelName | string | No | The model name. | qwen-vl-max |
| ModelPrompt | string | No | The prompt used when calling Qwen VL parsing. | #角色 你是一个专业的图片内容标注人员,擅长识别并描述出图片中的内容。 # 任务目标 请结合输入图片,详细描述图片中的内容。 |
| Tags | array | No | The list of tags associated with the file. Default value: empty, which means the file is not associated with any tags. A maximum of 10 tags can be specified. | |
string | No | The tag of the file. Each tag can be up to 12 characters in length and supports characters in the Unicode letter category (including English letters, Chinese characters, and digits), underscores (_), and hyphens (-). | 产品介绍 | |
| OverWriteFileByOssKey | boolean | No | Specifies whether to overwrite files with the same OssKey in the category. Default value: false, which means files are not overwritten. | false |
Response elements
Element | Type | Description | Example |
|---|---|---|---|
object | Schema of Response | ||
| Code | string | The error code. | success |
| Data | object | The data field returned by the operation. | |
| AddFileResultList | array<object> | The list of file import results. | |
object | The list of file import results. | ||
| FileId | string | The file ID. Please keep this value safe, as it will be used for all subsequent API operations related to this file. | file_809f469a59ac449586ec692576xxxxx_102248XXX |
| OssKey | string | The key name (Key) of the imported file in the OSS Bucket. | root/path/this_is_temp_xxxx.pdf |
| Status | string | File import status. Possible values:
Only files with the SUCCESS status can be used to create or update knowledge bases. | SUCCESS |
| Msg | string | Error information returned when file import fails. | size too large |
| Message | string | The error message. | Cant find out category for category_id param. |
| RequestId | string | The request ID. | 17204B98-xxxx-4F9A-8464-2446A84821CA |
| Status | string | The status code returned by the operation. | 200 |
| Success | string | Indicates whether the call was successful. Valid values:
| true |
Examples
Success response
JSON format