Skip to main content

UploadDocument

Upload a document to a document library. The system parses the document, splits it into chunks, and builds an index.

Operation description

Make sure that you fully understand the billing methods and pricing of Tongyi Dianjin before you use this operation. Prerequisites
  • Alibaba Cloud Model Studio and Tongyi Dianjin are activated.
  • You have obtained the workspace ID. For more information about how to obtain it, see workspace identifier.

Debug

You can run this API directly in OpenAPI Explorer, which saves you the trouble of calculating signatures. After the operation succeeds, OpenAPI Explorer can automatically generate SDK code examples. Debug

Authorization information

The following table describes the authorization information of this API. You can use the Action element in RAM permission policy statements to grant RAM users or RAM roles the permissions to call this API. For more details:
  • Action: the specific permission point.
  • Access level: the access level of each operation. Valid values: Write, Read, or List.
  • Resource type: the resource types that support authorization for the operation. For more details:
    • For required resource types, a leading asterisk (*) is added.
    • For operations that do not support resource-level authorization, All Resources is used.
  • Condition key: the condition keys defined by the cloud service itself.
  • Dependent action: other permissions required to successfully perform the operation. The caller must have the permissions of all dependent actions for the operation to succeed.
ActionAccess levelResource typeCondition keyDependent action
dianjin:UploadDocumentnone
*All Resources
*
    None
None

Request syntax

POST /{workspaceId}/api/library/document/upload HTTP/1.1

Request parameters

ParameterTypeRequiredDescriptionExample
workspaceIdstringYes

Path parameter. The workspace ID.

llm-xxxxx
bodyobjectNo

The request body.

datastringNo

File metadata, which can be used as a filter during retrieval.

{\"cateogry\": \"Report\"}
fileNamestringYes

The full file name (including the extension). Currently, pdf, doc, docx, markdown, ppt, and pptx are supported. The file size is limited to 100 MB, and pdf, doc, docx, ppt, and pptx files are limited to 500 pages.

test.pdf
fileUrlstringYes

The OSS URL of the file. If the file is not publicly readable, fileUrl must carry signature parameters.

If you use an SDK to upload files, you can upload the file directly without providing an OSS URL. For more information, see the SDK documentation.

https://oss-xxx.hangzhou.com/test.pdf
libraryIdstringYes

The document library ID.

sjdhbcsj

Response parameters

NameTypeDescriptionExample
object

The response result.

costlong

The elapsed time.

null
datastring

The returned data.

1782981430906818562
dataTypestring

The data type.

null
errCodestring

The error code.

0
messagestring

The error message.

ok
requestIdstring

The request ID.

ff3fef67-48d9-4379-a237-9ba8143fe739
successboolean

Indicates whether the operation is successful.

true
timestring

The timestamp.

2024-04-24 11:54:34

Examples

Success response example JSON format
{
  "cost": 0,
  "data": 1782981430906818600,
  "dataType": null,
  "errCode": 0,
  "message": "ok",
  "requestId": "ff3fef67-48d9-4379-a237-9ba8143fe739",
  "success": true,
  "time": "2024-04-24 11:54:34"
}

Error codes

Visit the Error Center to view more error codes.