Appearance
AddFilesFromAuthorizedOss
Imports unstructured documents from an authorized Object Storage Service (OSS) bucket into your application in Alibaba Cloud Model Studio. This API operation does not support importing structured data. To import structured data, you can use the console.
Operation description
The OSS bucket and Alibaba Cloud Model Studio must be under the same Alibaba Cloud account. You must also grant the required permissions. For more information, see Configure permissions to import data from OSS.
The supported storage classes for buckets do not include Archive, Cold Archive, or Deep Cold Archive. Encrypted or private buckets are supported.
Make sure that hotlink protection based on the Referer header is disabled for the bucket. Otherwise, Alibaba Cloud Model Studio cannot import files from the bucket.
A RAM user must obtain database permissions for Alibaba Cloud Model Studio and join a workspace before calling this operation. The RAM user needs the
AliyunBailianDataFullAccesspermission, which includes thesfm:AddFilesFromAuthorizedOsspermission. An Alibaba Cloud account can call this operation without authorization. To call this operation, use the latest version of the Alibaba Cloud Model Studio SDK.This operation is not idempotent.
Throttling: Frequent calls to this operation are throttled. Do not exceed a frequency of 5 calls per second. If a call is throttled, you can retry it 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
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.
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
HELPCODEESCAPE-plaintext
POST /{WorkspaceId}/datacenter/file/fromoss HTTP/1.1Request parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| WorkspaceId | string | Yes | The ID of the workspace to which you want to import the unstructured documents. For more information about how to obtain the workspace ID, see Use workspaces. | llm-3z7uw7fwz0vxxxx |
| CategoryId | string | Yes | The ID of the destination category for the document import. This is the CategoryId returned by the AddCategory operation. You can also go to the Unstructured Data tab of the Application data page and click the ID icon next to a category name to obtain the category ID. You can set this parameter to default to use the default category created by the system. | cate_cdd11b1b79a74e8bbd675c356a91ee35xxxxxxxx |
| CategoryType | string | Yes | The category type. This parameter is optional. The default value is UNSTRUCTURED. Valid values: - UNSTRUCTURED: unstructured data, used for knowledge base scenarios. ** **Note ** This operation does not support importing SESSION_FILE. Use the AddFile operation to upload a SESSION_FILE from your local device. | 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 | Yes | The list of documents to import. ** **Note ** You can upload a maximum of 10 files at a time. | |
| object | Yes | The document object. | ||
| FileName | string | Yes | The name of the document to import. Make sure that the file name extension is included. Supported formats: pdf, docx, doc, txt, md, pptx, ppt, xlsx, xls, html, png, jpg, jpeg, bmp, and gif. The document name must be 4 to 128 characters in length. ** **Note ** To create a structured data table and upload data, use the Alibaba Cloud Model Studio console. This is not supported by API operations. | this_is_temp_xxxx.pdf |
| OssKey | string | Yes | The key of the imported document in the OSS bucket. For more information, see Object naming. | root/path/this_is_temp_xxxx.pdf |
| Tags | array | No | The list of tags associated with the document. The default value is empty, which means the document is not associated with any tags. You can specify a maximum of 10 tags. | |
| string | No | The tag of the document. Each tag can be up to 12 characters in length and can contain letters in the Unicode standard (including English letters, Chinese characters, and digits), underscores (_), and hyphens (-). | 产品介绍 |
Response elements
| Parameter | Type | Description | Example |
|---|---|---|---|
| object | Schema of Response | ||
| Code | string | The error code. | success |
| Data | object | The data returned for the operation. | |
| AddFileResultList | array | The list of document import results. | |
| object | |||
| FileId | string | The document ID. Keep this ID for future API operations related to this document. | file_809f469a59ac449586ec692576xxxxx_102248XXX |
| OssKey | string | The key of the imported document in the OSS bucket. | root/path/this_is_temp_xxxx.pdf |
| Status | string | The import status of the document. Valid values: - SUCCESS: The document is imported to the application data. - FAILED: The document failed to be imported to the application data. ** **Note ** Only documents with a status of SUCCESS can be used to create or update a knowledge base. | success |
| Msg | string | The error message returned when the document 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. | 200 |
| Success | string | Indicates whether the call was successful. Valid values: - true: The call was successful. - false: The call failed. | true |
Examples
Success response
JSON format
HELPCODEESCAPE-json
{
"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.