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

# Commit a file

> Call this API to commit a file. Documents the API call method, request parameters, and response structure.

Call this API to commit a file.

## API call description

The API call steps are as follows:

Step 1: Call the [Obtain file upload information](/open/development/obtain-file-upload-informations) API to obtain the information required for uploading the file.

Step 2: Upload the file by using the OSS header sign request method. Refer to the following examples:

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
public void test(){
               // Get the URL from the API response
                String resourceUrl = "resourceUrls obtained from the API in step 1";
              // Get the headers from the API response
                Map<String, String> headers = headers obtained from the API in step 1;
                URL url = new URL(resourceUrl);
                HttpURLConnection connection = (HttpURLConnection)url.openConnection();
               if (headers != null) {
                for (Map.Entry<String, String> entry : headers.entrySet()) {
                    connection.setRequestProperty(entry.getKey(), entry.getValue());
                }
            }
                connection.setDoOutput(true);
                connection.setRequestMethod("PUT");
                connection.setUseCaches(false);
                connection.setReadTimeout(10000);
                connection.setConnectTimeout(10000);
                connection.connect();
                OutputStream out = connection.getOutputStream();
                InputStream is = new FileInputStream(new File("/Users/xxxxx/Desktop/test_file.xls"));
                byte[] b =new byte[1024];
                int temp;
                while ((temp=is.read(b))!=-1){
                       out.write(b,0,temp);
                }
                out.flush();
                out.close();
                int responseCode = connection.getResponseCode();
                connection.disconnect();
                if (responseCode == 200) {
                    System.out.println("Upload succeeded");
                 } else {
                    System.out.println("Upload failed");
                 }
}
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
#!/usr/bin/env python

import requests

url = '<resourceUrl obtained from the API in step 1>'
headers = <headers returned by the API in step 1>
result = requests.put(url, data=open('<path_to_file>', 'rb'), headers=headers)
print(result)
```

C#

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
public static string HttpRequest(string url, string filePath, Dictionary<string, string> headers) {

    FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
    BinaryReader reader = new BinaryReader(fileStream);
    reader.BaseStream.Seek(0, SeekOrigin.Begin);
    byte[] datas = reader.ReadBytes((int)reader.BaseStream.Length);
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.Method = "PUT";
    request.Timeout = 150000;
    foreach (var header in headers) {
        request.Headers.Add($"{header.Key}", $"{header.Value}");
    }
    Stream requestStream = null;
    string responseStr = null;
    try {
        if (datas != null) {
            request.ContentLength = datas.Length;
            requestStream = request.GetRequestStream();
            requestStream.Write(datas, 0, datas.Length);
            requestStream.Close();
        } else {
            request.ContentLength = 0;
        }
        HttpWebResponse response = request.GetResponse() as HttpWebResponse;
        responseStr = response.Headers.GetValues("x-oss-request-id")[0];
    } catch (Exception ex) {
        Console.WriteLine("error");
    } finally {
        request = null;
        requestStream = null;
    }
    return responseStr;
}
```

PHP

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
$url = $result->body->headerSignatureInfo->resourceUrls[0];
$headersSource = $result->body->headerSignatureInfo->headers;
foreach ($headersSource as $key => $value) {
$headers[] = $key . ': ' . $value;
}
// You must explicitly set Content-Type to empty
$headers['Content-Type'] = '';

$file = '/Users/dengxian.ldx/Desktop/test.txt';

$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_TIMEOUT => 100,
CURLOPT_CONNECTTIMEOUT => 100,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_PUT => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
));
curl_setopt($ch, CURLOPT_INFILE, fopen($file , 'rb'));
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file) );
curl_setopt($ch, CURLOPT_UPLOAD, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response .PHP_EOL;
```

Node.js

```javascript theme={"theme":{"light":"github-light","dark":"github-dark"}}
const fs = require('fs');
const request = require('request-promise');

url = <url>;
header = <headers>;

// Note: You must explicitly set content-type to empty
headers['content-type']='';

var options = {
  method: 'PUT',
  url: url,
  headers: headers
};

fs.createReadStream('/Users/dengxian.ldx/temp/test/a.txt').pipe(request(options)).then(body =>{
  console.log(body);
}).catch(err => {
  console.log(err);
});
```

Step 3: Call this API to commit the file and complete the upload.

### Notes

* When the storage space type is USER, all users with permissions on the space have operation rights. Other employees must call the [Add permissions](/open/development/add-permissions-file) API to grant authorization.
* When the storage space type is APP, any operator must call the [Add permissions](/open/development/add-permissions-file) API to grant authorization.

## request

### Basic information

| Field                   | Value                                                                         |
| ----------------------- | ----------------------------------------------------------------------------- |
| HTTP URL                | `https://api.dingtalk.io/v2.0/storage/spaces/files/{parentDentryUuid}/commit` |
| HTTP Method             | POST                                                                          |
| Supported app types     | appType-Internal app　appType-Third-party enterprise app                       |
| Permission requirements | permission-Storage.File.Write-Organization storage file write permission      |

### request header

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

### path parameter

| Name             | Type   | Required | Description                                                                                                                                                                                                                                                                                                        |
| ---------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| parentDentryUuid | String | Yes      | The dentryUuid of the parent node. Call the [File Search](/open/development/search-for-files#) or [Get dentryUuid information](/open/development/api-getuuidbydentryid#) API to obtain the `dentryUuid` field from the response.    For the space root directory, pass the dentryUuid of the space root directory. |

### query parameter

| Name    | Type   | Required | Description                                                                                                     |
| ------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------- |
| unionId | String | Yes      | The unionId of the user. Call the [Query user details](/open/development/query-user-details#) API to obtain it. |

### request body

| Name               | Type    | Required | Description                                                                                                                                                                                                                                                |                              |
| ------------------ | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| uploadKey          | String  | Yes      | The unique identifier of the file to add. Call the [Obtain file upload information](/open/development/obtain-file-upload-informations#) API to obtain the value of the uploadKey parameter.                                                                |                              |
| name               | String  | Yes      | The file name, including the extension. Naming rules:- No leading or trailing spaces; otherwise they are automatically trimmed. - No special characters, including tab, `*`, `"`, `<`, `>`, \`                                                             | `. - Must not end with `.\`. |
| option             | Object  | No       | Optional parameters.                                                                                                                                                                                                                                       |                              |
| size               | Long    | No       | The default file size, in bytes.    If this field is not empty, the organization storage system verifies whether the actual file size matches this value. A mismatch causes an error.                                                                      |                              |
| conflictStrategy   | String  | No       | The file name conflict strategy.   - **AUTO\_RENAME**: Automatically rename. Default. - **OVERWRITE**: Overwrite. - **RETURN\_DENTRY\_IF\_EXISTS**: Return the existing file. - **RETURN\_ERROR\_IF\_EXISTS**: Return an error if the file already exists. |                              |
| appProperties      | Array   | No       | The app property list of the current file. Maximum: 3.                                                                                                                                                                                                     |                              |
| name               | String  | Yes      | The property name.    The property name must be unique within the current app. Properties with the same name across different apps do not affect each other.                                                                                               |                              |
| value              | String  | Yes      | The property value.                                                                                                                                                                                                                                        |                              |
| visibility         | String  | Yes      | The property visibility.   - **PUBLIC**: Visible to all apps. - **PRIVATE**: Visible only to the current app.                                                                                                                                              |                              |
| convertToOnlineDoc | Boolean | No       | Whether to convert to an online document.   - **false** (default): No. - **true**: Yes.                                                                                                                                                                    |                              |

### Request example

HTTP

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

{
  "uploadKey" : "upload_key",
  "name" : "dentry_name",
  "option" : {
    "size" : 512,
    "conflictStrategy" : "AUTO_RENAME",
    "appProperties" : [ {
      "name" : "property_name",
      "value" : "property_value",
      "visibility" : "PRIVATE"
    } ],
    "convertToOnlineDoc" : false
  }
}
```

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_2_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_2_0.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.dingtalkstorage_2_0.Client client = Sample.createClient();
        com.aliyun.dingtalkstorage_2_0.models.CommitFileHeaders commitFileHeaders = new com.aliyun.dingtalkstorage_2_0.models.CommitFileHeaders();
        commitFileHeaders.xAcsDingtalkAccessToken = "<your access token>";
        com.aliyun.dingtalkstorage_2_0.models.CommitFileRequest.CommitFileRequestOptionAppProperties optionAppProperties0 = new com.aliyun.dingtalkstorage_2_0.models.CommitFileRequest.CommitFileRequestOptionAppProperties()
                .setName("property_name")
                .setValue("property_value")
                .setVisibility("PRIVATE");
        com.aliyun.dingtalkstorage_2_0.models.CommitFileRequest.CommitFileRequestOption option = new com.aliyun.dingtalkstorage_2_0.models.CommitFileRequest.CommitFileRequestOption()
                .setSize(512L)
                .setConflictStrategy("AUTO_RENAME")
                .setAppProperties(java.util.Arrays.asList(
                    optionAppProperties0
                ))
                .setConvertToOnlineDoc(false);
        com.aliyun.dingtalkstorage_2_0.models.CommitFileRequest commitFileRequest = new com.aliyun.dingtalkstorage_2_0.models.CommitFileRequest()
                .setUnionId("union_id")
                .setUploadKey("upload_key")
                .setName("dentry_name")
                .setOption(option);
        try {
            client.commitFileWithOptions("uuid", commitFileRequest, commitFileHeaders, 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 to help developers 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 to help developers 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_2_0.client import Client as dingtalkstorage_2_0Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dingtalk.storage_2_0 import models as dingtalkstorage__2__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_2_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_2_0Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        commit_file_headers = dingtalkstorage__2__0_models.CommitFileHeaders()
        commit_file_headers.x_acs_dingtalk_access_token = '<your access token>'
        option_app_properties_0 = dingtalkstorage__2__0_models.CommitFileRequestOptionAppProperties(
            name='property_name',
            value='property_value',
            visibility='PRIVATE'
        )
        option = dingtalkstorage__2__0_models.CommitFileRequestOption(
            size=512,
            conflict_strategy='AUTO_RENAME',
            app_properties=[
                option_app_properties_0
            ],
            convert_to_online_doc=False
        )
        commit_file_request = dingtalkstorage__2__0_models.CommitFileRequest(
            union_id='union_id',
            upload_key='upload_key',
            name='dentry_name',
            option=option
        )
        try:
            client.commit_file_with_options('uuid', commit_file_request, commit_file_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 to help developers locate the issue
                pass

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        commit_file_headers = dingtalkstorage__2__0_models.CommitFileHeaders()
        commit_file_headers.x_acs_dingtalk_access_token = '<your access token>'
        option_app_properties_0 = dingtalkstorage__2__0_models.CommitFileRequestOptionAppProperties(
            name='property_name',
            value='property_value',
            visibility='PRIVATE'
        )
        option = dingtalkstorage__2__0_models.CommitFileRequestOption(
            size=512,
            conflict_strategy='AUTO_RENAME',
            app_properties=[
                option_app_properties_0
            ],
            convert_to_online_doc=False
        )
        commit_file_request = dingtalkstorage__2__0_models.CommitFileRequest(
            union_id='union_id',
            upload_key='upload_key',
            name='dentry_name',
            option=option
        )
        try:
            await client.commit_file_with_options_async('uuid', commit_file_request, commit_file_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 to help developers 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_2_0\Dingtalk;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Dingtalk\Vstorage_2_0\Models\CommitFileHeaders;
use AlibabaCloud\SDK\Dingtalk\Vstorage_2_0\Models\CommitFileRequest\option\appProperties;
use AlibabaCloud\SDK\Dingtalk\Vstorage_2_0\Models\CommitFileRequest\option;
use AlibabaCloud\SDK\Dingtalk\Vstorage_2_0\Models\CommitFileRequest;
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();
        $commitFileHeaders = new CommitFileHeaders([]);
        $commitFileHeaders->xAcsDingtalkAccessToken = "<your access token>";
        $optionAppProperties0 = new appProperties([
            "name" => "property_name",
            "value" => "property_value",
            "visibility" => "PRIVATE"
        ]);
        $option = new option([
            "size" => 512,
            "conflictStrategy" => "AUTO_RENAME",
            "appProperties" => [
                $optionAppProperties0
            ],
            "convertToOnlineDoc" => false
        ]);
        $commitFileRequest = new CommitFileRequest([
            "unionId" => "union_id",
            "uploadKey" => "upload_key",
            "name" => "dentry_name",
            "option" => $option
        ]);
        try {
            $client->commitFileWithOptions("uuid", $commitFileRequest, $commitFileHeaders, 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 to help developers 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_2_0  "github.com/alibabacloud-go/dingtalk/storage_2_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_2_0.Client, _err error) {
  config := &openapi.Config{}
  config.Protocol = tea.String("https")
  config.RegionId = tea.String("central")
  _result = &dingtalkstorage_2_0.Client{}
  _result, _err = dingtalkstorage_2_0.NewClient(config)
  return _result, _err
}

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

  commitFileHeaders := &dingtalkstorage_2_0.CommitFileHeaders{}
  commitFileHeaders.XAcsDingtalkAccessToken = tea.String("<your access token>")
  optionAppProperties0 := &dingtalkstorage_2_0.CommitFileRequestOptionAppProperties{
    Name: tea.String("property_name"),
    Value: tea.String("property_value"),
    Visibility: tea.String("PRIVATE"),
  }
  option := &dingtalkstorage_2_0.CommitFileRequestOption{
    Size: tea.Int64(512),
    ConflictStrategy: tea.String("AUTO_RENAME"),
    AppProperties: []*dingtalkstorage_2_0.CommitFileRequestOptionAppProperties{optionAppProperties0},
    ConvertToOnlineDoc: tea.Bool(false),
  }
  commitFileRequest := &dingtalkstorage_2_0.CommitFileRequest{
    UnionId: tea.String("union_id"),
    UploadKey: tea.String("upload_key"),
    Name: tea.String("dentry_name"),
    Option: option,
  }
  tryErr := func()(_e error) {
    defer func() {
      if r := tea.Recover(recover()); r != nil {
        _e = r
      }
    }()
    _, _err = client.CommitFileWithOptions(tea.String("uuid"), commitFileRequest, commitFileHeaders, &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 to help developers 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_2_0, * as $dingtalkstorage_2_0 from '@alicloud/dingtalk/storage_2_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_2_0 {
    let config = new $OpenApi.Config({ });
    config.protocol = "https";
    config.regionId = "central";
    return new dingtalkstorage_2_0(config);
  }

  static async main(args: string[]): Promise<void> {
    let client = Client.createClient();
    let commitFileHeaders = new $dingtalkstorage_2_0.CommitFileHeaders({ });
    commitFileHeaders.xAcsDingtalkAccessToken = "<your access token>";
    let optionAppProperties0 = new $dingtalkstorage_2_0.CommitFileRequestOptionAppProperties({
      name: "property_name",
      value: "property_value",
      visibility: "PRIVATE",
    });
    let option = new $dingtalkstorage_2_0.CommitFileRequestOption({
      size: 512,
      conflictStrategy: "AUTO_RENAME",
      appProperties: [
        optionAppProperties0
      ],
      convertToOnlineDoc: false,
    });
    let commitFileRequest = new $dingtalkstorage_2_0.CommitFileRequest({
      unionId: "union_id",
      uploadKey: "upload_key",
      name: "dentry_name",
      option: option,
    });
    try {
      await client.commitFileWithOptions("uuid", commitFileRequest, commitFileHeaders, new $Util.RuntimeOptions({ }));
    } catch (err) {
      if (!Util.empty(err.code) && !Util.empty(err.message)) {
        // err contains code and message properties to help developers 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_2_0.Client CreateClient()
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
            config.Protocol = "https";
            config.RegionId = "central";
            return new AlibabaCloud.SDK.Dingtalkstorage_2_0.Client(config);
        }

        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.Dingtalkstorage_2_0.Client client = CreateClient();
            AlibabaCloud.SDK.Dingtalkstorage_2_0.Models.CommitFileHeaders commitFileHeaders = new AlibabaCloud.SDK.Dingtalkstorage_2_0.Models.CommitFileHeaders();
            commitFileHeaders.XAcsDingtalkAccessToken = "<your access token>";
            AlibabaCloud.SDK.Dingtalkstorage_2_0.Models.CommitFileRequest.CommitFileRequestOption.CommitFileRequestOptionAppProperties optionAppProperties0 = new AlibabaCloud.SDK.Dingtalkstorage_2_0.Models.CommitFileRequest.CommitFileRequestOption.CommitFileRequestOptionAppProperties
            {
                Name = "property_name",
                Value = "property_value",
                Visibility = "PRIVATE",
            };
            AlibabaCloud.SDK.Dingtalkstorage_2_0.Models.CommitFileRequest.CommitFileRequestOption option = new AlibabaCloud.SDK.Dingtalkstorage_2_0.Models.CommitFileRequest.CommitFileRequestOption
            {
                Size = 512,
                ConflictStrategy = "AUTO_RENAME",
                AppProperties = new List<AlibabaCloud.SDK.Dingtalkstorage_2_0.Models.CommitFileRequest.CommitFileRequestOption.CommitFileRequestOptionAppProperties>
                {
                    optionAppProperties0
                },
                ConvertToOnlineDoc = false,
            };
            AlibabaCloud.SDK.Dingtalkstorage_2_0.Models.CommitFileRequest commitFileRequest = new AlibabaCloud.SDK.Dingtalkstorage_2_0.Models.CommitFileRequest
            {
                UnionId = "union_id",
                UploadKey = "upload_key",
                Name = "dentry_name",
                Option = option,
            };
            try
            {
                client.CommitFileWithOptions("uuid", commitFileRequest, commitFileHeaders, 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 to help developers 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 to help developers locate the issue
                }
            }
        }

    }
}
```

## response

### response body

| Name          | Type                 | Description                                                                                                                                                                                                             |
| ------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| dentry        | Object               | File information.                                                                                                                                                                                                       |
| id            | String               | The file ID.                                                                                                                                                                                                            |
| spaceId       | String               | The ID of the space the file belongs to.                                                                                                                                                                                |
| parentId      | String               | The parent directory ID. For the root directory, this value is 0.    An empty value means the root directory has no parentId.                                                                                           |
| type          | String               | The type, either directory or file. Enum values:   - **FILE**: File. - **FOLDER**: Folder.                                                                                                                              |
| name          | String               | The file name.                                                                                                                                                                                                          |
| size          | Long                 | The file size, in bytes.                                                                                                                                                                                                |
| path          | String               | The file path within the space.                                                                                                                                                                                         |
| version       | Long                 | The version.                                                                                                                                                                                                            |
| status        | String               | The status:   - **NORMAL**: Normal. - **DELETED**: Deleted. - **EXPIRED**: Expired.                                                                                                                                     |
| extension     | String               | The file extension.                                                                                                                                                                                                     |
| creatorId     | String               | The unionId of the creator.                                                                                                                                                                                             |
| modifierId    | String               | The unionId of the modifier.                                                                                                                                                                                            |
| createTime    | String               | The created time in ISO 8601 format, for example, 2022-07-29T14:55Z.                                                                                                                                                    |
| modifiedTime  | String               | The modified time in ISO 8601 format, for example, 2022-07-29T14:55Z.                                                                                                                                                   |
| properties    | Object               | File properties.                                                                                                                                                                                                        |
| readOnly      | Boolean              | Whether the file is read-only.   - **true**: Yes. - **false**: No.                                                                                                                                                      |
| appProperties | `Map<String, Array>` | Properties on specific apps. The key is the ownerId of the space, and the value is the property list.                                                                                                                   |
|               | Array                | The property list.                                                                                                                                                                                                      |
| name          | String               | The property name.                                                                                                                                                                                                      |
| value         | String               | The property value.                                                                                                                                                                                                     |
| visibility    | String               | The property visibility.   - **PUBLIC**: Visible to all apps. - **PRIVATE**: Visible only to the current app.                                                                                                           |
| uuid          | String               | The unique identifier uuid. This field does not change when the file is moved.                                                                                                                                          |
| partitionType | String               | The storage partition:   - **PUBLIC\_OSS\_PARTITION**: Public cloud OSS storage partition. - **MINI\_OSS\_PARTITION**: Dedicated MiniOSS storage partition.                                                             |
| storageDriver | String               | The driver type. Enum values:   - **DINGTALK**: DingTalk unified storage driver. - **ALIDOC**: DingTalk Docs storage driver. - **SHANJI**: Shanji storage driver. - **UNKNOWN**: Unknown driver.                        |
| thumbnail     | Object               | Thumbnail information.                                                                                                                                                                                                  |
| width         | Integer              | The thumbnail width.                                                                                                                                                                                                    |
| height        | Integer              | The thumbnail height.                                                                                                                                                                                                   |
| url           | String               | The thumbnail URL.                                                                                                                                                                                                      |
| category      | String               | The category. Enum values:   - **IMAGE**: Image. - **VIDEO**: Video. - **AUDIO**: Audio. - **ARCHIVE**: Archive. - **SHORTCUT**: Shortcut. - **DOCUMENT**: Document. - **ALI\_DOC**: DingTalk Docs. - **OTHER**: Other. |

### Response body example

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

{
  "dentry" : {
    "id" : "dentry_id",
    "spaceId" : "space_id",
    "parentId" : "parent_id",
    "type" : "FILE",
    "name" : "dentry_name",
    "size" : 512,
    "path" : "dentry_path",
    "version" : 1,
    "status" : "NORMAL",
    "extension" : "txt",
    "creatorId" : "creator_id",
    "modifierId" : "modifier_id",
    "createTime" : "2022-01-01T10:00:00Z",
    "modifiedTime" : "2022-01-01T10:00:00Z",
    "properties" : {
      "readOnly" : true
    },
    "appProperties" : [ {
      "name" : "property_name",
      "value" : "property_value",
      "visibility" : "PRIVATE"
    } ],
    "uuid" : "uuid",
    "partitionType" : "PUBLIC_OSS_PARTITION",
    "storageDriver" : "DINGTALK",
    "thumbnail" : {
      "width" : 64,
      "height" : 64,
      "url" : "url"
    },
    "category" : "DOCUMENT"
  }
}
```

### Error codes

If an error is returned when you call this API, find a solution by error message in the [Global error codes](/open/development/server-api-error-codes-1) document.

| HttpCode | Error code                  | Error message | Description                                   |
| -------- | --------------------------- | ------------- | --------------------------------------------- |
| 400      | operationConcurrentControl  | %s            | Concurrency control.                          |
| 400      | paramError                  | %s            | Parameter error.                              |
| 400      | paramError.parentDentryUuid | %s            | Parameter error - parentDentryUuid.           |
| 400      | paramError.uploadKey        | %s            | Parameter error - uploadKey.                  |
| 400      | paramError.name             | %s            | Parameter error - name.                       |
| 400      | paramError.conflictStrategy | %s            | Parameter error - conflictStrategy.           |
| 400      | spaceQuotaInsufficient      | %s            | Insufficient space quota.                     |
| 400      | sceneQuotaInsufficient      | %s            | Insufficient scene quota.                     |
| 400      | appQuotaInsufficient        | %s            | Insufficient app quota.                       |
| 400      | orgQuotaInsufficient        | %s            | Insufficient organization quota.              |
| 400      | dentryNameIllegal           | %s            | Illegal file name.                            |
| 400      | dentryStoreError            | %s            | File storage error.                           |
| 400      | dentryNameConflict          | %s            | File name conflict.                           |
| 400      | dentryFormatNotSupport      | %s            | Unsupported file format.                      |
| 403      | permissionDenied            | %s            | The user lacks permission to upload the file. |
| 404      | spaceNotExist               | %s            | The space does not exist.                     |
| 500      | systemError                 | %s            | System error.                                 |
| 500      | unknownError                | Unknown Error | Unknown error.                                |
| 503      | operationTimeout            | %s            | Request timeout.                              |
