> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Initialize a multipart file upload

> Call this API to initialize a multipart file upload task and obtain the upload ID and parameters for subsequent part uploads.

Call this API to initialize a multipart file upload.

## 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 identifier `uploadKey`.

Step 2: Call the [Get multipart file upload information](/open/development/obtains-the-information-about-multipart-uploads-of-an-object) 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](/open/development/submittal-file) API to complete the upload.

For a complete example, see the following:

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
import com.aliyun.dingtalkstorage_1_0.models.*;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.teautil.models.RuntimeOptions;
import com.util.AccessTokenUtil;
import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;
import java.util.Map;

public class MultipartUpload {
    public static com.aliyun.dingtalkstorage_1_0.Client createClient() throws Exception {
        Config config = new Config();
        config.protocol = "https";
        config.regionId = "central";
        return new com.aliyun.dingtalkstorage_1_0.Client(config);
    }
    @Test
    public void test() throws Exception {
        com.aliyun.dingtalkstorage_1_0.Client client = MultipartUpload.createClient();

        String spaceId = "Space ID";
        String filePath = "/Users/xxxxx/Desktop/music.mp3";
        // Size of each file part
        long partSize = 1 * 1024 * 1024L;  // 1MB
        // Initialize the multipart upload API
        InitMultipartFileUploadHeaders initMultipartFileUploadHeaders = new InitMultipartFileUploadHeaders();
        initMultipartFileUploadHeaders.xAcsDingtalkAccessToken = "accessToken";
        InitMultipartFileUploadRequest initMultipartFileUploadRequest = new InitMultipartFileUploadRequest();
        initMultipartFileUploadRequest.setUnionId(unionId);
        InitMultipartFileUploadRequest.InitMultipartFileUploadRequestOption initMultipartFileUploadRequestOption = new InitMultipartFileUploadRequest.InitMultipartFileUploadRequestOption();
        initMultipartFileUploadRequestOption.setStorageDriver("DINGTALK");
        initMultipartFileUploadRequest.setOption(initMultipartFileUploadRequestOption);
        String uploadKey = client.initMultipartFileUploadWithOptions(spaceId, initMultipartFileUploadRequest, initMultipartFileUploadHeaders, new RuntimeOptions()).getBody().getUploadKey();

        File file = new File(filePath);
        long fileLength = file.length();
        int partCount = (int) (fileLength / partSize) + ((fileLength % partSize != 0) ? 1 : 0);

        for (int i = 0; i < partCount; i++) {
            long startPos = i * partSize;
            long curPartSize = (i + 1 == partCount) ? (fileLength - startPos) : partSize;
            // Get multipart upload information
            GetMultipartFileUploadInfosHeaders getMultipartFileUploadInfosHeaders = new GetMultipartFileUploadInfosHeaders();
            getMultipartFileUploadInfosHeaders.xAcsDingtalkAccessToken = "accessToken";
            GetMultipartFileUploadInfosRequest getMultipartFileUploadInfosRequest = new GetMultipartFileUploadInfosRequest();
            getMultipartFileUploadInfosRequest.setUnionId(unionId);
            getMultipartFileUploadInfosRequest.setUploadKey("uploadKey obtained from the multipart upload initialization API in Step 1");
            getMultipartFileUploadInfosRequest.setPartNumbers(Arrays.asList(i + 1));
            GetMultipartFileUploadInfosResponseBody.GetMultipartFileUploadInfosResponseBodyMultipartHeaderSignatureInfosHeaderSignatureInfo headerSignatureInfo = client.getMultipartFileUploadInfosWithOptions(getMultipartFileUploadInfosRequest, getMultipartFileUploadInfosHeaders, new RuntimeOptions()).body.multipartHeaderSignatureInfos.get(0).headerSignatureInfo;
            uploadPartFile(startPos, curPartSize, headerSignatureInfo, file);
        }
            // Commit the file to complete the upload
            CommitFileHeaders commitFileHeaders = new CommitFileHeaders();
            commitFileHeaders.xAcsDingtalkAccessToken = "accessToken";
            CommitFileRequest.CommitFileRequestOption commitFileRequestOption
                = new CommitFileRequest.CommitFileRequestOption()
                .setSize(1024L)
                .setConflictStrategy("OVERWRITE");
            CommitFileRequest commitFileRequest = new CommitFileRequest()
                .setUnionId(unionId)
                .setUploadKey("uploadKey obtained from the multipart upload initialization API in Step 1")
                .setName("music.mp3")
                .setParentId("0")
                .setOption(commitFileRequestOption);
            CommitFileResponseBody.CommitFileResponseBodyDentry dentry = client.commitFileWithOptions("Space ID", commitFileRequest, commitFileHeaders, new RuntimeOptions()).body.dentry;
            System.out.println(dentry);
    }

    private void uploadPartFile(long start, long size, GetMultipartFileUploadInfosResponseBody.GetMultipartFileUploadInfosResponseBodyMultipartHeaderSignatureInfosHeaderSignatureInfo headerSignatureInfo, File file) throws Exception {
        InputStream inputStream = new FileInputStream(file);
        if (start > 0) {
            inputStream.skip(start);
        }

        URL url = new URL(headerSignatureInfo.getResourceUrls().get(0));
        HttpURLConnection connection = (HttpURLConnection)url.openConnection();
        connection.setDoOutput(true);
        connection.setRequestMethod("PUT");
        connection.setUseCaches(false);
        if (headerSignatureInfo.getHeaders() != null) {
            for (Map.Entry<String, String> entry : headerSignatureInfo.getHeaders().entrySet()) {
                connection.setRequestProperty(entry.getKey(), entry.getValue());
            }
        }
        connection.setReadTimeout(10000);
        connection.setConnectTimeout(10000);
        connection.connect();
        OutputStream out = connection.getOutputStream();
        byte[] buffer = new byte[1024];
        long remain = size;
        for (;remain > 0;) {
            int sizeToRead = remain < buffer.length ? (int)remain : buffer.length;
            int rsz = inputStream.read(buffer, 0, sizeToRead);
            if (rsz < 0) {
                break;
            }
            out.write(buffer, 0, rsz);
            remain -= rsz;
        }
        out.flush();
        out.close();
        int responseCode = connection.getResponseCode();
        if (responseCode == 200) {
            System.out.println("Upload succeeded");
        } else {
            System.out.println("Upload failed");
        }
        connection.disconnect();
    }
}
```

## 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](/open/development/obtain-the-access-token-of-an-internal-app#) API. - For a third-party enterprise app, call the [Get the access token of the authorized enterprise](https://open.dingtalk.com/document/development/obtain-the-access-token-of-the-authorized-enterprise-1#) API. |

### Path parameters

| Name    | Type   | Required | Description                                                                                                     |
| ------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------- |
| spaceId | String | Yes      | The space ID. Call the [Add space](/open/development/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](/open/development/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](https://open.dingtalk.com/document/development/obtain-the-file-list-storage#) 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

HTTP

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
POST /v1.0/storage/spaces/568xxxxx/files/multiPartUploadInfos/init?unionId=chyxxxxx HTTP/1.1
Host:api.dingtalk.io
x-acs-dingtalk-access-token:xxxxx
Content-Type:application/json

{
  "option" : {
    "storageDriver" : "DINGTALK",
    "preCheckParam" : {
      "md5" : "md5",
      "size" : 512,
      "parentId" : "897xxxxx",
      "name" : "test-file.txt"
    },
    "preferRegion" : "ZHANGJIAKOU"
  }
}
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * Initialize the account Client with a token
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.dingtalkstorage_1_0.Client createClient() throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
        config.protocol = "https";
        config.regionId = "central";
        return new com.aliyun.dingtalkstorage_1_0.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.dingtalkstorage_1_0.Client client = Sample.createClient();
        com.aliyun.dingtalkstorage_1_0.models.InitMultipartFileUploadHeaders initMultipartFileUploadHeaders = new com.aliyun.dingtalkstorage_1_0.models.InitMultipartFileUploadHeaders();
        initMultipartFileUploadHeaders.xAcsDingtalkAccessToken = "<your access token>";
        com.aliyun.dingtalkstorage_1_0.models.InitMultipartFileUploadRequest.InitMultipartFileUploadRequestOptionPreCheckParam optionPreCheckParam = new com.aliyun.dingtalkstorage_1_0.models.InitMultipartFileUploadRequest.InitMultipartFileUploadRequestOptionPreCheckParam()
                .setMd5("md5")
                .setSize(512L)
                .setParentId("897xxxxx")
                .setName("test-file.txt");
        com.aliyun.dingtalkstorage_1_0.models.InitMultipartFileUploadRequest.InitMultipartFileUploadRequestOption option = new com.aliyun.dingtalkstorage_1_0.models.InitMultipartFileUploadRequest.InitMultipartFileUploadRequestOption()
                .setStorageDriver("DINGTALK")
                .setPreCheckParam(optionPreCheckParam)
                .setPreferRegion("ZHANGJIAKOU");
        com.aliyun.dingtalkstorage_1_0.models.InitMultipartFileUploadRequest initMultipartFileUploadRequest = new com.aliyun.dingtalkstorage_1_0.models.InitMultipartFileUploadRequest()
                .setUnionId("chyxxxxx")
                .setOption(option);
        try {
            client.initMultipartFileUploadWithOptions("568xxxxx", initMultipartFileUploadRequest, initMultipartFileUploadHeaders, new com.aliyun.teautil.models.RuntimeOptions());
        } catch (TeaException err) {
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // err contains code and message properties that help locate the issue
            }

        } catch (Exception _err) {
            TeaException err = new TeaException(_err.getMessage(), _err);
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // err contains code and message properties that help locate the issue
            }

        }        
    }
}
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import sys

from typing import List

from alibabacloud_dingtalk.storage_1_0.client import Client as dingtalkstorage_1_0Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dingtalk.storage_1_0 import models as dingtalkstorage__1__0_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient

class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> dingtalkstorage_1_0Client:
        """
        Initialize the account Client with a token
        @return: Client
        @throws Exception
        """
        config = open_api_models.Config()
        config.protocol = 'https'
        config.region_id = 'central'
        return dingtalkstorage_1_0Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        init_multipart_file_upload_headers = dingtalkstorage__1__0_models.InitMultipartFileUploadHeaders()
        init_multipart_file_upload_headers.x_acs_dingtalk_access_token = '<your access token>'
        option_pre_check_param = dingtalkstorage__1__0_models.InitMultipartFileUploadRequestOptionPreCheckParam(
            md_5='md5',
            size=512,
            parent_id='897xxxxx',
            name='test-file.txt'
        )
        option = dingtalkstorage__1__0_models.InitMultipartFileUploadRequestOption(
            storage_driver='DINGTALK',
            pre_check_param=option_pre_check_param,
            prefer_region='ZHANGJIAKOU'
        )
        init_multipart_file_upload_request = dingtalkstorage__1__0_models.InitMultipartFileUploadRequest(
            union_id='chyxxxxx',
            option=option
        )
        try:
            client.init_multipart_file_upload_with_options('568xxxxx', init_multipart_file_upload_request, init_multipart_file_upload_headers, util_models.RuntimeOptions())
        except Exception as err:
            if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
                # err contains code and message properties that help locate the issue
                pass

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        init_multipart_file_upload_headers = dingtalkstorage__1__0_models.InitMultipartFileUploadHeaders()
        init_multipart_file_upload_headers.x_acs_dingtalk_access_token = '<your access token>'
        option_pre_check_param = dingtalkstorage__1__0_models.InitMultipartFileUploadRequestOptionPreCheckParam(
            md_5='md5',
            size=512,
            parent_id='897xxxxx',
            name='test-file.txt'
        )
        option = dingtalkstorage__1__0_models.InitMultipartFileUploadRequestOption(
            storage_driver='DINGTALK',
            pre_check_param=option_pre_check_param,
            prefer_region='ZHANGJIAKOU'
        )
        init_multipart_file_upload_request = dingtalkstorage__1__0_models.InitMultipartFileUploadRequest(
            union_id='chyxxxxx',
            option=option
        )
        try:
            await client.init_multipart_file_upload_with_options_async('568xxxxx', init_multipart_file_upload_request, init_multipart_file_upload_headers, util_models.RuntimeOptions())
        except Exception as err:
            if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
                # err contains code and message properties that help locate the issue
                pass

if __name__ == '__main__':
    Sample.main(sys.argv[1:])
```

PHP

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
<?php

// This file is auto-generated, don't edit it. Thanks.
namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\Dingtalk\Vstorage_1_0\Dingtalk;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Dingtalk\Vstorage_1_0\Models\InitMultipartFileUploadHeaders;
use AlibabaCloud\SDK\Dingtalk\Vstorage_1_0\Models\InitMultipartFileUploadRequest\option\preCheckParam;
use AlibabaCloud\SDK\Dingtalk\Vstorage_1_0\Models\InitMultipartFileUploadRequest\option;
use AlibabaCloud\SDK\Dingtalk\Vstorage_1_0\Models\InitMultipartFileUploadRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class Sample {

    /**
     * Initialize the account Client with a token
     * @return Dingtalk Client
     */
    public static function createClient(){
        $config = new Config([]);
        $config->protocol = "https";
        $config->regionId = "central";
        return new Dingtalk($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient();
        $initMultipartFileUploadHeaders = new InitMultipartFileUploadHeaders([]);
        $initMultipartFileUploadHeaders->xAcsDingtalkAccessToken = "<your access token>";
        $optionPreCheckParam = new preCheckParam([
            "md5" => "md5",
            "size" => 512,
            "parentId" => "897xxxxx",
            "name" => "test-file.txt"
        ]);
        $option = new option([
            "storageDriver" => "DINGTALK",
            "preCheckParam" => $optionPreCheckParam,
            "preferRegion" => "ZHANGJIAKOU"
        ]);
        $initMultipartFileUploadRequest = new InitMultipartFileUploadRequest([
            "unionId" => "chyxxxxx",
            "option" => $option
        ]);
        try {
            $client->initMultipartFileUploadWithOptions("568xxxxx", $initMultipartFileUploadRequest, $initMultipartFileUploadHeaders, new RuntimeOptions([]));
        }
        catch (Exception $err) {
            if (!($err instanceof TeaError)) {
                $err = new TeaError([], $err->getMessage(), $err->getCode(), $err);
            }
            if (!Utils::empty_($err->code) && !Utils::empty_($err->message)) {
                // err contains code and message properties that help locate the issue
            }
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
Sample::main(array_slice($argv, 1));
```

Go

```go theme={"theme":{"light":"github-light","dark":"github-dark"}}
// This file is auto-generated, don't edit it. Thanks.
package main

import (
  "os"
  util  "github.com/alibabacloud-go/tea-utils/v2/service"
  dingtalkstorage_1_0  "github.com/alibabacloud-go/dingtalk/storage_1_0"
  openapi  "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  "github.com/alibabacloud-go/tea/tea"
)

/**
 * Initialize the account Client with a token
 * @return Client
 * @throws Exception
 */
func CreateClient () (_result *dingtalkstorage_1_0.Client, _err error) {
  config := &openapi.Config{}
  config.Protocol = tea.String("https")
  config.RegionId = tea.String("central")
  _result = &dingtalkstorage_1_0.Client{}
  _result, _err = dingtalkstorage_1_0.NewClient(config)
  return _result, _err
}

func _main (args []*string) (_err error) {
  client, _err := CreateClient()
  if _err != nil {
    return _err
  }

  initMultipartFileUploadHeaders := &dingtalkstorage_1_0.InitMultipartFileUploadHeaders{}
  initMultipartFileUploadHeaders.XAcsDingtalkAccessToken = tea.String("<your access token>")
  optionPreCheckParam := &dingtalkstorage_1_0.InitMultipartFileUploadRequestOptionPreCheckParam{
    Md5: tea.String("md5"),
    Size: tea.Int64(512),
    ParentId: tea.String("897xxxxx"),
    Name: tea.String("test-file.txt"),
  }
  option := &dingtalkstorage_1_0.InitMultipartFileUploadRequestOption{
    StorageDriver: tea.String("DINGTALK"),
    PreCheckParam: optionPreCheckParam,
    PreferRegion: tea.String("ZHANGJIAKOU"),
  }
  initMultipartFileUploadRequest := &dingtalkstorage_1_0.InitMultipartFileUploadRequest{
    UnionId: tea.String("chyxxxxx"),
    Option: option,
  }
  tryErr := func()(_e error) {
    defer func() {
      if r := tea.Recover(recover()); r != nil {
        _e = r
      }
    }()
    _, _err = client.InitMultipartFileUploadWithOptions(tea.String("568xxxxx"), initMultipartFileUploadRequest, initMultipartFileUploadHeaders, &util.RuntimeOptions{})
    if _err != nil {
      return _err
    }

    return nil
  }()

  if tryErr != nil {
    var err = &tea.SDKError{}
    if _t, ok := tryErr.(*tea.SDKError); ok {
      err = _t
    } else {
      err.Message = tea.String(tryErr.Error())
    }
    if !tea.BoolValue(util.Empty(err.Code)) && !tea.BoolValue(util.Empty(err.Message)) {
      // err contains code and message properties that help locate the issue
    }

  }
  return _err
}

func main() {
  err := _main(tea.StringSlice(os.Args[1:]))
  if err != nil {
    panic(err)
  }
}
```

Node.js

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
// This file is auto-generated, don't edit it
import Util, * as $Util from '@alicloud/tea-util';
import dingtalkstorage_1_0, * as $dingtalkstorage_1_0 from '@alicloud/dingtalk/storage_1_0';
import OpenApi, * as $OpenApi from '@alicloud/openapi-client';
import * as $tea from '@alicloud/tea-typescript';

export default class Client {

  /**
   * Initialize the account Client with a token
   * @return Client
   * @throws Exception
   */
  static createClient(): dingtalkstorage_1_0 {
    let config = new $OpenApi.Config({ });
    config.protocol = "https";
    config.regionId = "central";
    return new dingtalkstorage_1_0(config);
  }

  static async main(args: string[]): Promise<void> {
    let client = Client.createClient();
    let initMultipartFileUploadHeaders = new $dingtalkstorage_1_0.InitMultipartFileUploadHeaders({ });
    initMultipartFileUploadHeaders.xAcsDingtalkAccessToken = "<your access token>";
    let optionPreCheckParam = new $dingtalkstorage_1_0.InitMultipartFileUploadRequestOptionPreCheckParam({
      md5: "md5",
      size: 512,
      parentId: "897xxxxx",
      name: "test-file.txt",
    });
    let option = new $dingtalkstorage_1_0.InitMultipartFileUploadRequestOption({
      storageDriver: "DINGTALK",
      preCheckParam: optionPreCheckParam,
      preferRegion: "ZHANGJIAKOU",
    });
    let initMultipartFileUploadRequest = new $dingtalkstorage_1_0.InitMultipartFileUploadRequest({
      unionId: "chyxxxxx",
      option: option,
    });
    try {
      await client.initMultipartFileUploadWithOptions("568xxxxx", initMultipartFileUploadRequest, initMultipartFileUploadHeaders, new $Util.RuntimeOptions({ }));
    } catch (err) {
      if (!Util.empty(err.code) && !Util.empty(err.message)) {
        // err contains code and message properties that help locate the issue
      }

    }    
  }

}

Client.main(process.argv.slice(2));
```

C#

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
// This file is auto-generated, don't edit it. Thanks.

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

using Tea;
using Tea.Utils;

namespace AlibabaCloud.SDK.Sample
{
    public class Sample 
    {

        /**
         * Initialize the account Client with a token
         * @return Client
         * @throws Exception
         */
        public static AlibabaCloud.SDK.Dingtalkstorage_1_0.Client CreateClient()
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
            config.Protocol = "https";
            config.RegionId = "central";
            return new AlibabaCloud.SDK.Dingtalkstorage_1_0.Client(config);
        }

        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.Dingtalkstorage_1_0.Client client = CreateClient();
            AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.InitMultipartFileUploadHeaders initMultipartFileUploadHeaders = new AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.InitMultipartFileUploadHeaders();
            initMultipartFileUploadHeaders.XAcsDingtalkAccessToken = "<your access token>";
            AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.InitMultipartFileUploadRequest.InitMultipartFileUploadRequestOption.InitMultipartFileUploadRequestOptionPreCheckParam optionPreCheckParam = new AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.InitMultipartFileUploadRequest.InitMultipartFileUploadRequestOption.InitMultipartFileUploadRequestOptionPreCheckParam
            {
                Md5 = "md5",
                Size = 512,
                ParentId = "897xxxxx",
                Name = "test-file.txt",
            };
            AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.InitMultipartFileUploadRequest.InitMultipartFileUploadRequestOption option = new AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.InitMultipartFileUploadRequest.InitMultipartFileUploadRequestOption
            {
                StorageDriver = "DINGTALK",
                PreCheckParam = optionPreCheckParam,
                PreferRegion = "ZHANGJIAKOU",
            };
            AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.InitMultipartFileUploadRequest initMultipartFileUploadRequest = new AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.InitMultipartFileUploadRequest
            {
                UnionId = "chyxxxxx",
                Option = option,
            };
            try
            {
                client.InitMultipartFileUploadWithOptions("568xxxxx", initMultipartFileUploadRequest, initMultipartFileUploadHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
            }
            catch (TeaException err)
            {
                if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
                {
                    // err contains code and message properties that help locate the issue
                }
            }
            catch (Exception _err)
            {
                TeaException err = new TeaException(new Dictionary<string, object>
                {
                    { "message", _err.Message }
                });
                if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
                {
                    // err contains code and message properties that help locate the issue
                }
            }
        }

    }
}
```

## Response

### 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

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
HTTP/1.1 200 OK
Content-Type:application/json

{
  "uploadKey" : "xhy89xxxxx",
  "storageDriver" : "DINGTALK"
}
```

### Error codes

If an error is returned when you call this API, search for the error message in the [Global error codes](/open/development/server-api-error-codes-1) 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                                 |
