All Products
Search
Document Center

Drive and Photo Service:CreateFile

Last Updated:Mar 26, 2026

Creates a file or folder.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

POST /v2/file/create HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The request parameters.

name

string

Yes

The name of the file. The name can be up to 1,024 bytes in length based on the UTF-8 encoding rule and cannot contain forward slash (/).

a.txt

type

string

Yes

The type of the file. Valid values:

file folder

file

parent_file_id

string

Yes

The ID of the parent directory. If you want to create a file or folder in the root directory, set this parameter to root.

fileid1

drive_id

string

No

The drive ID. This parameter is required if the file is not uploaded by using the share URL of the file.

1

share_id

string

No

The share ID. This parameter is required if the file is uploaded by using the share URL of the file.

7JQX1FswpQ8

size

integer

No

The size of the file. Unit: bytes.

1024

content_type

string

No

The type of the file content. Default value: application/oct-stream.

application/json

part_info_list

array<object>

No

The information about the file parts. You can specify up to 10,000 parts. By default, if you do not specify this parameter, only one part is returned.

array<object>

No

part_number

integer

No

The serial number of a file part. The number starts from 1.

1

parallel_sha1_ctx

object

No

The SHA-1 hash value of the file content before the file part. This parameter takes effect only if the parallel upload feature is enabled.

h

array

No

The first to fifth 32-bit variables of the SHA-1 hash value of the file content before the file part. This parameter takes effect only if the parallel upload feature is enabled.

integer

No

The first to fifth 32-bit variables of the SHA-1 hash value of the file content before the file part.

1

part_offset

integer

No

The size of the file content before the file part. Unit: bytes. The value must be a multiple of 64. This parameter takes effect only if the parallel upload feature is enabled.

10240

content_md5

string

No

The MD5 hash value of the file part. This parameter is required when the MD5 hash value of the file part needs to be verified during part upload.

ASKJDJSKDJJSJDJS

user_tags

array

No

The custom tags. You can specify up to 1,000 tags.

UserTag

No

The custom tag.

hidden

boolean

No

Specifies whether to hide the file or folder. By default, the file or folder is not hidden.

false

description

string

No

The description of the file. The description can be up to 1,024 characters in length. By default, this parameter is left empty.

Team files

content_hash

string

No

The hash value of the file content. The value is calculated based on the algorithm specified by content_hash_name.

7C4A8D09CA3762AF61E59520943DC26494F8941B

content_hash_name

string

No

The name of the algorithm that is used to calculate the hash value of the file content. Only SHA1 is supported.

sha1

pre_hash

string

No

The SHA-1 hash value of the first 1 KB data of the file. This parameter is required if you perform instant file upload by using the pre-hashing feature. If the SHA-1 hash value is not matched on the cloud, the client does not need to calculate the SHA-1 hash value of the entire file.

7C4A8D09CA3762AF61E59520943DC26494F89411

check_name_mode

string

No

The processing method that is used if the file that you want to create has the same name as an existing file in the cloud. Valid values:

ignore: allows you to create the file by using the same name as an existing file in the cloud.

auto_rename: automatically renames the file that you want to create. By default, the current point in time is added to the end of the file name. Example: xxx_20060102_150405.

refuse: does not create the file that you want to create but returns the information about the file that has the same name in the cloud.

Default value: ignore.

Valid values:

  • refuse :

    refuse

  • auto_rename :

    auto_rename

  • ignore :

    ignore

ignore

file_id

string

No

The file ID. This parameter is required if check_name_mode is set to ignore.

9520943DC264

local_created_at

string

No

The time when the local file was created. By default, this parameter is left empty. Specify the time in the yyyy-MM-ddTHH:mm:ssZ format based on the UTC+0 time zone.

2019-08-20T06:51:27.292Z

local_modified_at

string

No

The time when the local file was modified. By default, this parameter is left empty. Specify the time in the yyyy-MM-ddTHH:mm:ssZ format based on the UTC+0 time zone.

2019-08-20T06:51:27.292Z

image_media_metadata ImageMediaMetadata

No

The information about the image specified by the client.

video_media_metadata VideoMediaMetadata

No

The information about the video specified by the client.

parallel_upload

boolean

No

Specifies whether to enable the parallel upload feature.

true

Response elements

Element

Type

Description

Example

object

The data returned.

parent_file_id

string

The ID of the parent directory.

fileid5

part_info_list

array

The information about the file parts.

UploadPartInfo

The information about a file part.

upload_id

string

The ID of the upload task.

uploadid1

rapid_upload

boolean

Indicates whether the file is instantly uploaded.

true

type

string

The type of the file.

file

file_id

string

The file ID.

fileid1

domain_id

string

The domain ID.

bj1

drive_id

string

The drive ID.

1

file_name

string

The file name.

a.txt

status

string

The state of the file.

uploading

exist

boolean

Indicates whether the file exists.

false

Examples

Success response

JSON format

{
  "parent_file_id": "fileid5",
  "part_info_list": [
    {
      "part_number": 1,
      "part_size": 1024,
      "upload_url": "",
      "internal_upload_url": "",
      "etag": "0CC175B9C0F1B6A831C399E269772661",
      "parallel_sha1_ctx": {
        "h": [
          0
        ],
        "part_offset": 0
      },
      "upload_form_info": {
        "bucket_name": "",
        "oss_end_point": "",
        "object_key": "",
        "oss_access_key_id": "",
        "oss_security_token": "",
        "policy": "",
        "signature": "",
        "endpoint": "",
        "form_data": {
          "key": ""
        }
      },
      "internal_upload_form_info": {
        "bucket_name": "",
        "oss_end_point": "",
        "object_key": "",
        "oss_access_key_id": "",
        "oss_security_token": "",
        "policy": "",
        "signature": "",
        "endpoint": "",
        "form_data": {
          "key": ""
        }
      },
      "signature_info": {
        "auth_type": "",
        "signature": "",
        "sts_token": ""
      },
      "parallel_sha256_ctx": {
        "h": [
          0
        ],
        "part_offset": 0
      }
    }
  ],
  "upload_id": "uploadid1",
  "rapid_upload": true,
  "type": "file",
  "file_id": "fileid1",
  "domain_id": "bj1",
  "drive_id": "1",
  "file_name": "a.txt",
  "status": "uploading",
  "exist": false
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.