Request an upload lease for uploading knowledge base files or files for agent application conversational interactions.
Operation description
- RAM users (sub-accounts) must first obtain API permissions for Alibaba Cloud Model Studio (requires
AliyunBailianDataFullAccess, which includes the sfm:ApplyFileUploadLease permission), and join a workspace before calling this API. Alibaba Cloud accounts (primary accounts) can directly call this API without authorization. We recommend that you call this API by using the latest Alibaba Cloud Model Studio SDK. - This API is not idempotent.
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:ApplyFileUploadLease | none | *全部资源
| None | None |
Request syntax
Path Parameters
Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| CategoryId | string | Yes | When uploading files for building a knowledge base:
To create a new data table and upload data, use the Alibaba Cloud Model Studio console. This is not supported through the API.
| cate_cdd11b1b79a74e8bbd675c356a91ee35xxxxxxxx |
| WorkspaceId | string | Yes | The ID of the workspace to which the uploaded file belongs. For information about how to obtain the workspace ID, see How to use workspaces. | llm-3z7uw7fwz0vexxxx |
Request parameters
Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| FileName | string | Yes | When uploading files for building a knowledge base:
To create a new data table and upload data, use the Alibaba Cloud Model Studio console. This is not supported through the API. | XXXX产品清单.pdf |
| Md5 | string | Yes | The MD5 value of the uploaded file. The server will verify this field (currently not enabled). Please fill in the correct value. | 19657c391f6c70bcea63c154d8606bb3 |
| SizeInBytes | string | Yes | The size of the uploaded file in bytes. The server will verify this field (currently not enabled). Please fill in the correct value. Valid values: 1 B to 100 MB. | 1000 |
| CategoryType | string | No | The category type. If this parameter is not specified, the default value is UNSTRUCTURED. Valid values: UNSTRUCTURED: category for building knowledge base scenarios. SESSION_FILE: upload files for agent application conversational interactions. To create a new data table and upload data, use the Alibaba Cloud Model Studio console. This is not supported through the API. | UNSTRUCTURED |
| UseInternalEndpoint | boolean | No | If you have enabled Alibaba Cloud Model Studio secure storage and need to generate a lease URL that is only accessible from the Alibaba Cloud internal network in the same region, you can set this parameter to true to improve security. If this parameter is not specified, the default value is false, which generates a publicly accessible lease URL. If you have not enabled Alibaba Cloud Model Studio secure storage, or are unsure whether you are using it, do not set this parameter to true (upload will fail). | false |
Response elements
Element | Type | Description | Example |
|---|---|---|---|
object | Schema of Response | ||
| Code | string | The error code. | DataCenter.FileTooLarge |
| Data | object | The data returned. | |
| FileUploadLeaseId | string | The unique ID of the lease. You need to use this parameter when you call the AddFile API. | 1e6a159107384782be5e45ac4759b247.1719325231035 |
| Param | object | The HTTP request parameters for uploading the file. | |
| Headers | any | The key-value pairs to include in the HTTP request header. Both keys and values are strings. The returned Content-Type may be empty. Use the empty value as-is when uploading. | "X-bailian-extra":"MTAwNTQyNjQ5NTE2OTE3OA==", "Content-Type":"application/pdf" |
| Method | string | The HTTP method. Valid values:
| PUT |
| Url | string | The upload URL for the file. This URL is a pre-signed URL. It does not support FormData uploads. Use binary upload instead. | |
| Type | string | The upload method of the file. Valid values:
| HTTP |
| 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 returned. | 200 |
| Success | boolean | Indicates whether the API call is successful. Valid values:
| true |
Examples
Success response
JSON format