AddFilesFromAuthorizedOss

Updated at:
Copy as MD

Imports files from an authorized OSS Bucket into Alibaba Cloud Model Studio (Bailian) application data.

Operation description

  • Please ensure that the OSS Bucket and Alibaba Cloud Model Studio belong to the same Alibaba Cloud account (main account) and that authorization has been completed according to the Configuration instructions for importing data from OSS.

    • Supported Bucket storage types do not include Archive, Cold Archive, or Deep Cold Archive. Buckets with content encryption are supported. Public read/write, public read, and private Buckets are supported.

    • If you want to use a Bucket with Referer hotlink protection enabled, refer to Allow access only from trusted websites to add the domain *.console.aliyun.com to the Referer allowlist.

  • A RAM user (sub-account) must first obtain the API permissions for Alibaba Cloud Model Studio (requires AliyunBailianDataFullAccess, which includes the sfm:AddFilesFromAuthorizedOss permission point) and join a workspace before calling this operation. The Alibaba Cloud account (main account) can call this directly without authorization. We recommend that you call this operation through the latest version of the Alibaba Cloud Model Studio SDK.

  • This operation is not idempotent.

Throttling description: Frequent calls to this operation will be throttled. The frequency should not exceed 5 calls per second. If throttled, please 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:AddFilesFromAuthorizedOss

create

*All Resource

*

None None

Request syntax

POST /{WorkspaceId}/datacenter/file/fromoss HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

WorkspaceId

string

Yes

The workspace ID. Files will be imported into this workspace. For how to obtain it, see How to use workspaces.

llm-3z7uw7fwz0vxxxx

Request parameters

Parameter

Type

Required

Description

Example

CategoryId

string

Yes

Specifies the target category for file import. This is the CategoryId returned by the AddCategory operation. You can also obtain the category ID from the Application Data - Files tab by clicking the ID icon next to the category name. You can also pass in default, which uses the system-created "Default Category".

cate_cdd11b1b79a74e8bbd675c356a91ee35xxxxxxxx

CategoryType

string

Yes

Category type. Optional. The default value is UNSTRUCTURED. Valid values:

  • UNSTRUCTURED: Category used for building knowledge base scenarios.

Valid values:

  • UNSTRUCTURED :

    UNSTRUCTURED

UNSTRUCTURED

OssRegionId

string

Yes

The region ID of the OSS Bucket. For how to obtain it, see OSS regions and endpoints.

cn-beijing

OssBucketName

string

Yes

The OSS Bucket name. For details, see Buckets.

bucketNamexxxxx

FileDetails

array<object>

Yes

The list of files to import. Up to 10 files can be uploaded at a time.

Note

Up to 10 files can be uploaded at a time.

array<object>

Yes

File object.

FileName

string

Yes

The name of the file to import. Note that the suffix must include the file format type.

  • Supported formats: pdf, docx, doc, txt, md, pptx, ppt, xlsx, xls, html, png, jpg, jpeg, bmp, gif.

  • The file name length is limited to 4-128 characters.

  • For file upload requirements and limits, see Knowledge base quotas and limits.

Important When the imported file name duplicates an existing file name in the knowledge base, the operation still returns Status as SUCCESS, but the file will not actually be imported into the knowledge base, and the existing file with the same name remains unchanged. Please ensure that each imported file name is unique.
Note

To add a new data table and upload data, please use the Alibaba Cloud Model Studio console; the API does not support this.

this_is_temp_xxxx.pdf

OssKey

string

Yes

The key name (Key) of the imported file in the OSS Bucket. For details, see Object naming.

root/path/this_is_temp_xxxx.pdf

Parser

string

No

Parser type. Possible values include:

  • DOCMIND (Intelligent document parsing)

  • DOCMIND_DIGITAL (Digital document parsing)

  • DOCMIND_LLM_VERSION (LLM-based document parsing)

  • DASH_QWEN_VL_PARSER (Qwen VL parsing)

  • DOCMIND_LLM_VERSION_MEDIA (Audio/video parsing)

  • AUTO_SELECT (Automatically select parser)

Note The currently configured parser will be used to parse your uploaded files. If AUTO_SELECT is entered, the parser configured for the corresponding category will be used.

AUTO_SELECT

ParserConfig

object

No

Parser configuration. Required only when the parser type is set to Qwen VL parsing.

ModelName

string

No

Model name.

qwen-vl-max

ModelPrompt

string

No

The prompt used when invoking Qwen VL parsing.

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

Tags

array

No

The list of tags associated with the file. The default is empty, meaning the file is not associated with any tags. Up to 10 tags can be passed in.

string

No

The tag of the file. Each tag can contain up to 12 characters, supporting characters in the Unicode letter category (including English, Chinese, numbers, etc.), underscores (_), and hyphens (-).

产品介绍

OverWriteFileByOssKey

boolean

No

Whether to overwrite the same file in the category by OssKey. The default value is false, meaning no overwrite.

false

Response elements

Element

Type

Description

Example

object

Schema of Response

Code

string

Error status code.

success

Data

object

Business 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. Store this ID securely. It is required for subsequent API operations on this file.

file_809f469a59ac449586ec692576xxxxx_102248XXX

OssKey

string

The key of the imported file in the OSS bucket.

root/path/this_is_temp_xxxx.pdf

Status

string

The import status of the file. Valid values:

  • SUCCESS: The import is complete.

  • FAILED: The import failed.

Note

Only files with a status of SUCCESS can be used to create or update a knowledge base.

SUCCESS

Msg

string

The error message returned when the file import fails.

size too large

Message

string

Error information.

Cant find out category for category_id param.

RequestId

string

The ID of the request.

17204B98-xxxx-4F9A-8464-2446A84821CA

Status

string

The status code returned by the operation.

200

Success

string

Whether the operation call succeeded. Possible values:

  • true: Success.

  • false: Failure.

true

Examples

Success response

JSON format

{
  "Code": "success",
  "Data": {
    "AddFileResultList": [
      {
        "FileId": "file_809f469a59ac449586ec692576xxxxx_102248XXX",
        "OssKey": "root/path/this_is_temp_xxxx.pdf",
        "Status": "SUCCESS",
        "Msg": "size too large"
      }
    ]
  },
  "Message": "Cant find out category for category_id param.",
  "RequestId": "17204B98-xxxx-4F9A-8464-2446A84821CA",
  "Status": "200",
  "Success": "true"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.