CreateFile

Updated at: 2025-04-03 08:11

Creates a file or folder.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

There is currently no authorization information disclosed in the API.

Request syntax

POST /v2/file/create HTTP/1.1

Request parameters

ParameterTypeRequiredDescriptionExample
ParameterTypeRequiredDescriptionExample
bodyobjectNo

The request parameters.

namestringYes

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
typestringYes

The type of the file. Valid values:

file folder

file
parent_file_idstringYes

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_idstringNo

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

1
share_idstringNo

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

7JQX1FswpQ8
sizelongNo

The size of the file. Unit: bytes.

1024
content_typestringNo

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

application/json
part_info_listarray<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.

objectNo
part_numberintegerNo

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

1
parallel_sha1_ctxobjectNo

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.

harrayNo

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.

longNo

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

1
part_offsetlongNo

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_md5stringNo

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_tagsarrayNo

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

UserTagNo

The custom tag.

hiddenbooleanNo

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

false
descriptionstringNo

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

content_hashstringNo

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

7C4A8D09CA3762AF61E59520943DC26494F8941B
content_hash_namestringNo

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

sha1
pre_hashstringNo

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_modestringNo

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.

ignore
file_idstringNo

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

9520943DC264
local_created_atstringNo

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_atstringNo

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_metadataImageMediaMetadataNo

The information about the image specified by the client.

video_media_metadataVideoMediaMetadataNo

The information about the video specified by the client.

parallel_uploadbooleanNo

Specifies whether to enable the parallel upload feature.

true

Response parameters

ParameterTypeDescriptionExample
ParameterTypeDescriptionExample
object

The data returned.

parent_file_idstring

The ID of the parent directory.

fileid5
part_info_listarray

The information about the file parts.

UploadPartInfo

The information about a file part.

upload_idstring

The ID of the upload task.

uploadid1
rapid_uploadboolean

Indicates whether the file is instantly uploaded.

true
typestring

The type of the file.

file
file_idstring

The file ID.

fileid1
domain_idstring

The domain ID.

bj1
drive_idstring

The drive ID.

1
file_namestring

The file name.

a.txt
statusstring

The state of the file.

uploading
existboolean

Indicates whether the file exists.

false

Examples

Sample success responses

JSONformat

{
  "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

For a list of error codes, visit the Service error codes.

  • On this page (1)
  • Debugging
  • Authorization information
  • Request syntax
  • Request parameters
  • Response parameters
  • Examples
  • Error codes
Feedback