API call description
To call the API, follow these steps: Step 1: Call this API to initialize the multipart file upload and obtain the upload identifieruploadKey.
Step 2: Call the Get multipart file upload information API to obtain the upload information for each part.
Step 3: Upload each part in a loop.
Step 4: Use the uploadKey obtained in Step 1 to call the Commit File API to complete the upload.
For a complete example, see the following:
Request
Basic information
| Field | Value |
|---|---|
| HTTP URL | https://api.dingtalk.io/v1.0/storage/spaces/{spaceId}/files/multiPartUploadInfos/init |
| HTTP Method | POST |
| Supported app types | appType-Internal app appType-Third-party enterprise app |
| Required permissions | permission-Storage.UploadInfo.Read-Read permission for organization storage file upload information |
Request headers
| Name | Type | Required | Description |
|---|---|---|---|
| x-acs-dingtalk-access-token | String | Yes | The access credential for calling this API. Obtain it as follows: - For an internal app, call the Get the access token of an internal app API. - For a third-party enterprise app, call the Get the access token of the authorized enterprise API. |
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| spaceId | String | Yes | The space ID. Call the Add space API to obtain the value of the id parameter. |
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
| unionId | String | Yes | The unionId of the operator. Call the Query user details API to obtain it. |
Request body
| Name | Type | Required | Description | |
|---|---|---|---|---|
| option | Object | No | Optional parameters. | |
| storageDriver | String | No | The file storage driver type. Currently, only DINGTALK is supported. | |
| preCheckParam | Object | No | Fields used for pre-checks. Used to validate the file name, file integrity, and capacity. | |
| md5 | String | No | The MD5 value of the file, generated by DigestUtils.md5Hex(). Used for file integrity validation. If not provided, no validation is performed. | |
| size | Long | No | The file size, in bytes. Used for capacity-related validation. If not provided, no validation is performed. | |
| parentId | String | No | The parent folder ID. For the root folder, this parameter is 0. Call the Get the file or folder list API to obtain the value of the parentId parameter. Used for file name conflict checks within the same folder. | |
| name | String | No | The file name. The naming rules are as follows: - Leading and trailing spaces are not allowed and will be automatically removed. - The following special characters are not allowed: tab, *, ", <, >, ` | . - The name cannot end with .`. - Used for file name validity and conflict checks. |
| preferRegion | String | No | The preferred region. - ZHANGJIAKOU: Zhangjiakou - SHENZHEN: Shenzhen - SHANGHAI: Shanghai - SINGAPORE: Singapore - UNKNOWN: Unknown Indicates the region where resources should preferentially be stored, enabling features such as nearby uploads. |
Request example
HTTPResponse
Response body
| Name | Type | Description |
|---|---|---|
| uploadKey | String | The unique upload identifier. |
| storageDriver | String | The file storage type. - DINGTALK: DingTalk unified storage driver - ALIDOC: DingTalk Docs storage driver - SHANJI: Shanji storage driver - UNKNOWN: Unknown driver |
Response body example
Error codes
If an error is returned when you call this API, search for the error message in the Global error codes document for a solution.| HttpCode | Error code | Error message | Description |
|---|---|---|---|
| 400 | paramError | %s | Parameter error |
| 400 | paramError.multipart | %s | Parameter error - multipart |
| 400 | paramError.protocol | %s | Parameter error - protocol |
| 400 | paramError.spaceId | %s | Parameter error - spaceId |
| 400 | paramError.storageDriver | %s | Parameter error - storageDriver |
| 400 | spaceQuotaInsufficient | %s | Insufficient space capacity |
| 400 | sceneQuotaInsufficient | %s | Insufficient scenario capacity |
| 400 | appQuotaInsufficient | %s | Insufficient app capacity |
| 400 | orgQuotaInsufficient | %s | Insufficient organization capacity |
| 400 | dentryUploadForbidden | %s | Upload forbidden |
| 400 | dentryUploadProtocolNotSupport | %s | Unsupported upload protocol |
| 403 | permissionDenied | %s | The user does not have permission to upload files |
| 404 | spaceNotExist | %s | The space does not exist |
| 500 | systemError | %s | System error |
| 500 | unknownError | Unknown Error | Unknown error |
| 503 | operationTimeout | %s | Request timed out |