Creates a file or folder.
Operation description
For the method of creating a file, refer to Best Practices: File upload.
During the file upload procedure, uploaded file parts incur storage fees. Parts are retained for 10 days until the file upload is complete or the parts expire and are cleaned up after 10 days.
Try it now
Test
RAM authorization
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 parameters. |
|
| name |
string |
Yes |
The file name. The name can be up to 1024 bytes in UTF-8 encoding and cannot contain forward slashes (/). |
a.txt |
| type |
string |
Yes |
The file type. Valid values:
|
file |
| parent_file_id |
string |
Yes |
The parent folder ID. Set this parameter to root to upload to the root directory. |
fileid1 |
| drive_id |
string |
No |
The drive ID. This parameter is required unless the upload is performed through a share link. |
1 |
| share_id |
string |
No |
The share ID. This parameter is required when uploading through a share link. |
7JQX1FswpQ8 |
| size |
integer |
No |
The file size, in bytes. |
1024 |
| content_type |
string |
No |
The file content type. Default value: application/oct-stream. |
application/json |
| part_info_list |
array<object> |
No |
The list of part information. A maximum of 10000 parts are supported. If this parameter is not specified, one part is returned by default. |
|
|
array<object> |
No |
The part information. |
||
| part_number |
integer |
No |
The part sequence number, starting from 1. |
1 |
| parallel_sha1_ctx |
object |
No |
The SHA1 context of all data before this part. This field is valid only in the concurrent multi-part upload mode. |
|
| h |
array |
No |
The first through fifth 32-bit variables of the contextual SHA1 of all data before this part. This field is valid only in the concurrent multi-part upload pattern. |
|
|
integer |
No |
The first through fifth 32-bit variables of the contextual SHA1 of all data before this part. |
1 |
|
| part_offset |
integer |
No |
The total length in bytes up to the previous data block. The value must be a multiple of 64. This field is valid only in the concurrent multi-part upload mode. |
10240 |
| content_md5 |
string |
No |
The MD5 value of the part. Specify this parameter when you need to verify the MD5 of the part during upload. |
ASKJDJSKDJJSJDJS |
| content_type |
string |
No |
The Content-Type value that the client must set when uploading a part by using PUT. If the Content-Type specified by the client during upload does not match this value, a signature error occurs. Default value: empty. The client does not need to specify Content-Type during PUT. |
application/json |
| user_tags |
array |
No |
The custom user tags. A maximum of 1000 tags are supported. |
|
| UserTag |
No |
The custom user tag. |
||
| description |
string |
No |
The file description. The description can be up to 1024 characters. Default value: empty. |
Team file. |
| 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 hash algorithm name for the file content. Currently, only sha1 is supported. |
sha1 |
| pre_hash |
string |
No |
The SHA1 value of the first 1 KB of the file. Specify this parameter when using the pre-rapid-upload feature. If no match is found on the server, the client does not need to calculate the full SHA1 of the file for rapid upload. |
7C4A8D09CA3762AF61E59520943DC26494F89411 |
| check_name_mode |
string |
No |
The mode for handling files with duplicate names. Valid values:
Default value: ignore. Valid values:
|
ignore |
| file_id |
string |
No |
The file ID. This parameter is required for overwrite operations. |
9520943DC264 |
| local_created_at |
string |
No |
The local creation time of the file. Default value: empty. Format: yyyy-MM-ddTHH:mm:ssZ, in UTC+0 time zone. |
2023-10-04T14:30:00Z |
| local_modified_at |
string |
No |
The local modification time of the file. Default value: empty. Format: yyyy-MM-ddTHH:mm:ssZ, in UTC+0 time zone. |
2023-10-04T14:30:00Z |
| parallel_upload |
boolean |
No |
Specifies whether to enable the parallel part upload feature. |
true |
| upload_type |
string |
No |
The upload type. Valid values: multipart and form. Default value: multipart. |
multipart |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response information. |
||
| parent_file_id |
string |
The parent folder ID. |
fileid5 |
| part_info_list |
array |
The list of part information. |
|
| UploadPartInfo |
The part information. |
||
| upload_id |
string |
The upload ID. |
uploadid1 |
| rapid_upload |
boolean |
Indicates whether the file was rapidly uploaded. |
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
},
"upload_form_info": {
"endpoint": "",
"form_data": {
"key": ""
}
},
"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.