All Products
Search
Document Center

Drive and Photo Service:CreateFile

Last Updated:May 12, 2026

Create a file or folder.

Operation description

For best practices on creating files, see File upload.

During a file upload, file chunks incur storage costs. These chunks have a 10-day retention period and are automatically deleted either when the upload is complete or after this period.

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

domain_id

string

Yes

body

object

No

The request body.

name

string

Yes

The file name. The name must be UTF-8 encoded, up to 1,024 bytes in length, and cannot contain the / character.

a.txt

type

string

Yes

The file type. Valid values are:

file: A file.
folder: A folder.

file

parent_file_id

string

Yes

The ID of the parent directory. Set this parameter to root to upload the file to the root directory.

fileid1

drive_id

string

No

The drive ID. This parameter is required unless you upload the file via a share link.

1

share_id

string

No

The share ID. This parameter is required when you upload a file via a share link.

7JQX1FswpQ8

size

integer

No

The file size, in bytes.

1024

content_type

string

No

The content type of the file. The default value is application/octet-stream.

application/json

part_info_list

array<object>

No

The part list. You can specify a maximum of 10,000 parts. If this parameter is omitted, the file is treated as a single-part upload.

array<object>

No

A file part.

part_number

integer

No

The part number, starting from 1.

1

parallel_sha1_ctx

object

No

The SHA-1 context of all data preceding this part. This parameter is valid only for parallel uploads.

h

array

No

The first five 32-bit variables of the SHA-1 context for all data preceding this part. This parameter is valid only for parallel uploads.

integer

No

One of the first five 32-bit variables of the SHA-1 context for all data preceding this part.

1

part_offset

integer

No

The total length, in bytes, of all data preceding this part. The value must be a multiple of 64. This parameter is valid only for parallel uploads.

10240

content_md5

string

No

The MD5 hash of the part. This parameter is required if you want to verify the integrity of the part during upload.

ASKJDJSKDJJSJDJS

content_type

string

No

application/json

user_tags

array

No

The user-defined tags. You can specify a maximum of 1,000 tags.

UserTag

No

A user-defined tag.

hidden

boolean

No

Specifies whether to hide the file or folder. The default value is false.

false

description

string

No

The file description, with a maximum length of 1,024 characters. By default, this parameter is empty.

团队文件

content_hash

string

No

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

7C4A8D09CA3762AF61E59520943DC26494F8941B

content_hash_name

string

No

The name of the hash algorithm used to calculate content_hash. Currently, only sha1 is supported.

sha1

pre_hash

string

No

The SHA-1 hash of the first 1 KB of the file. This parameter enables the rapid upload pre-check feature. This feature allows the client to avoid calculating the full file hash for a rapid upload attempt if the pre-check fails.

7C4A8D09CA3762AF61E59520943DC26494F89411

check_name_mode

string

No

The policy for handling file name conflicts. Valid values are:

ignore: Allows files with the same name.

auto_rename: Automatically renames the file if a file with the same name already exists. By default, the current timestamp is appended to the file name, for example, xxx_20060102_150405.

refuse: Rejects the request if a file with the same name already exists and returns the existing file's details.

The default value is ignore.

Valid values:

  • refuse :

    refuse

  • auto_rename :

    auto_rename

  • ignore :

    ignore

ignore

file_id

string

No

The file ID. This parameter is required to overwrite an existing file.

9520943DC264

local_created_at

string

No

The local creation time of the file. The time must be in yyyy-MM-ddTHH:mm:ssZ format (UTC). By default, this parameter is empty.

2023-10-04T14:30:00Z

local_modified_at

string

No

The local modification time of the file. The time must be in yyyy-MM-ddTHH:mm:ssZ format (UTC). By default, this parameter is empty.

2023-10-04T14:30:00Z

parallel_upload

boolean

No

Set to true to enable the parallel upload of parts.

true

upload_type

string

No

multipart

Response elements

Element

Type

Description

Example

object

The response.

parent_file_id

string

The ID of the parent directory.

fileid5

part_info_list

array

A list of details for each upload part.

UploadPartInfo

The details of an upload part.

upload_id

string

The upload ID.

uploadid1

rapid_upload

boolean

Indicates whether rapid upload was used.

true

type

string

The file type.

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 file status.

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": "https://data.aliyunpds.com/xxx/xxx?Expires=xxx&OSSAccessKeyId=xxx&Signature=xxx&partNumber=1&uploadId=0CC175B9C0F1B6A831C399E269772661",
      "internal_upload_url": "https://data-vpc.aliyunpds.com/xxx/xxx?Expires=xxx&OSSAccessKeyId=xxx&Signature=xxx&partNumber=1&uploadId=0CC175B9C0F1B6A831C399E269772661\n",
      "etag": "\"0CC175B9C0F1B6A831C399E269772661\"",
      "parallel_sha1_ctx": {
        "h": [
          0
        ],
        "part_offset": 10240
      },
      "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.