Creates a file or folder.
Debugging
Authorization information
Request syntax
POST /v2/file/create HTTP/1.1
Request parameters
Parameter | Type | Required | Description | Example |
---|
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. | |
size | long | 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. | |
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. | |
long | 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 | long | 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 | ||||
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. | |
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. | 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 parameters
Examples
Sample success responses
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
For a list of error codes, visit the Service error codes.