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.
Throttling: This API is subject to throttling if called too frequently. The frequency must not exceed 10 calls per second. If throttled, please retry later.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
sfm:ApplyFileUploadLease |
none |
*全部资源
|
None | None |
Request syntax
POST /{WorkspaceId}/datacenter/category/{CategoryId} HTTP/1.1
Path Parameters
|
Parameter |
Type |
Required |
Description |
Example |
| CategoryId |
string |
Yes |
When uploading files for building a knowledge base:
Note
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:
Note
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. Note
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. Note
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. Note
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. Note
This URL is a pre-signed URL. It does not support FormData uploads. Use binary upload instead. |
https://bailian-datahub-data-origin-prod.oss-cn-hangzhou.aliyuncs.com/1005426495169178/10024405/68abd1dea7b6404d8f7d7b9f7fbd332d.1716698936847.pdf?Expires=1716699536&OSSAccessKeyId=TestID&Signature=HfwPUZo4pR6DatSDym0zFKVh9Wg%3D |
| 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
{
"Code": "DataCenter.FileTooLarge",
"Data": {
"FileUploadLeaseId": "1e6a159107384782be5e45ac4759b247.1719325231035",
"Param": {
"Headers": "\"X-bailian-extra\":\"MTAwNTQyNjQ5NTE2OTE3OA==\",\n\"Content-Type\":\"application/pdf\"",
"Method": "PUT",
"Url": "https://bailian-datahub-data-origin-prod.oss-cn-hangzhou.aliyuncs.com/1005426495169178/10024405/68abd1dea7b6404d8f7d7b9f7fbd332d.1716698936847.pdf?Expires=1716699536&OSSAccessKeyId=TestID&Signature=HfwPUZo4pR6DatSDym0zFKVh9Wg%3D"
},
"Type": "HTTP"
},
"Message": "User not authorized to operate on the specified resource",
"RequestId": "778C0B3B-xxxx-5FC1-A947-36EDD13606AB",
"Status": "200",
"Success": true
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.