Skip to content

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 AliyunBailianDataFullAccess permission, which includes the sfm:AddFilesFromAuthorizedOss permission. 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 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.

ActionAccess levelResource typeCondition keyDependent action
sfm:AddFilesFromAuthorizedOsscreate*All Resource *NoneNone

Request syntax

HELPCODEESCAPE-plaintext
POST /{WorkspaceId}/datacenter/file/fromoss HTTP/1.1

Request parameters

ParameterTypeRequiredDescriptionExample
WorkspaceIdstringYesThe 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
CategoryIdstringYesThe 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
CategoryTypestringYesThe 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
OssRegionIdstringYesThe region ID of the OSS bucket. For more information, see OSS regions and endpoints.cn-beijing
OssBucketNamestringYesThe name of the OSS bucket. For more information, see Buckets.bucketNamexxxxx
FileDetailsarrayYesThe list of documents to import. ** **Note ** You can upload a maximum of 10 files at a time.
objectYesThe document object.
FileNamestringYesThe 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
OssKeystringYesThe key of the imported document in the OSS bucket. For more information, see Object naming.root/path/this_is_temp_xxxx.pdf
TagsarrayNoThe 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.
stringNoThe 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

ParameterTypeDescriptionExample
objectSchema of Response
CodestringThe error code.success
DataobjectThe data returned for the operation.
AddFileResultListarrayThe list of document import results.
object
FileIdstringThe document ID. Keep this ID for future API operations related to this document.file_809f469a59ac449586ec692576xxxxx_102248XXX
OssKeystringThe key of the imported document in the OSS bucket.root/path/this_is_temp_xxxx.pdf
StatusstringThe 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
MsgstringThe error message returned when the document import fails.size too large
MessagestringThe error message.Cant find out category for category_id param.
RequestIdstringThe request ID.17204B98-xxxx-4F9A-8464-2446A84821CA
StatusstringThe status code returned.200
SuccessstringIndicates 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.

Mirror of Alibaba Cloud Model Studio docs for reference and RAG. Not affiliated with Alibaba Cloud.