全部產品
Search
文件中心

Drive and Photo Service:CreateFile - 建立檔案或檔案夾

更新時間:Feb 26, 2026

建立檔案或檔案夾。

介面說明

檔案建立使用方法參考最佳實務:檔案上傳

檔案上傳過程中,已上傳的檔案分區會產生儲存費用。分區將保留 10 天,直到檔案上傳完成或 10 天后分區到期被清理。

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

當前API暫無授權資訊透出。

請求文法

POST /v2/file/create HTTP/1.1

請求參數

名稱

類型

必填

描述

樣本值

body

object

請求體參數。

name

string

檔案名稱,按照 utf8 編碼最長 1024 位元組,不能包含 /

a.txt

type

string

檔案類型,可選值如下:

file:檔案 folder:檔案夾

file

parent_file_id

string

父目錄 id,上傳到根目錄時填寫 root

fileid1

drive_id

string

空間 id,除通過分享連結上傳之外,必填

1

share_id

string

分享 id,當通過分享連結上傳時必填

7JQX1FswpQ8

size

integer

檔案大小,單位為 byte。

1024

content_type

string

檔案內容類型,預設值 application/oct-stream

application/json

part_info_list

array<object>

分區資訊列表,最多 10000 個分區,當不填時,預設返回 1 個分區

array<object>

分區資訊

part_number

integer

分區序號,從 1 開始

1

parallel_sha1_ctx

object

該分區前所有資料的 SHA1 上下文,該欄位只在多分區並發上傳的模式下有效

h

array

該分區前所有資料的 SHA1 內容相關的第 1-5 個 32 位變數,該欄位只在多分區並發上傳的模式下有效

integer

該分區前所有資料的 SHA1 內容相關的第 1-5 個 32 位變數

1

part_offset

integer

到上一個資料區塊為止的總長度,位元組,需要為 64 的倍數,該欄位只在多分區並發上傳的模式下有效

10240

content_md5

string

分區的 MD5, 需要在上傳分區時校正分區的 MD5 時填寫。

ASKJDJSKDJJSJDJS

user_tags

array

使用者自訂 tag,最多 1000 個 tag

UserTag

使用者自訂 tag

hidden

boolean

是否隱藏,預設不隱藏

false

description

string

檔案描述資訊,最長 1024 字元,預設為空白

團隊檔案

content_hash

string

檔案內容 hash 值,需要根據 content_hash_name 指定的演算法計算

7C4A8D09CA3762AF61E59520943DC26494F8941B

content_hash_name

string

檔案內容 hash 演算法名,當前只支援 sha1

sha1

pre_hash

string

使用預秒傳功能時填寫,為檔案前 1KB sha1 值,當遠端沒有匹配上時,用戶端無需再計算檔案完整 sha1 去嘗試秒傳。

7C4A8D09CA3762AF61E59520943DC26494F89411

check_name_mode

string

同名檔案處理模式,可選值如下:

ignore:允許同名檔案;

auto_rename:當發現同名檔案是,雲端自動重新命名,預設為追加目前時間點,如 xxx _20060102_150405;

refuse:當雲端存在同名檔案時,拒絕建立新檔案,返回用戶端已存在同名檔案的詳細資料。

預設為 ignore

枚舉值:

  • refuse :

    refuse

  • auto_rename :

    auto_rename

  • ignore :

    ignore

ignore

file_id

string

檔案 id,覆蓋寫時必填

9520943DC264

local_created_at

string

檔案本地建立時間,預設為空白,格式為:yyyy-MM-ddTHH:mm:ssZ,採用 UTC +0 時區

2023-10-04T14:30:00Z

local_modified_at

string

檔案本地修改時間,預設為空白,格式為:yyyy-MM-ddTHH:mm:ssZ,採用 UTC +0 時區

2023-10-04T14:30:00Z

image_media_metadata ImageMediaMetadata

用戶端指定的圖片資訊

video_media_metadata VideoMediaMetadata

用戶端指定的視頻資訊

parallel_upload

boolean

是否開啟並行上傳分區功能

true

返回參數

名稱

類型

描述

樣本值

object

返回資訊

parent_file_id

string

父目錄 id

fileid5

part_info_list

array

分段資訊列表

UploadPartInfo

分段資訊

upload_id

string

上傳 id

uploadid1

rapid_upload

boolean

是否已經秒傳

true

type

string

檔案類型

file

file_id

string

檔案 id

fileid1

domain_id

string

域 id

bj1

drive_id

string

空間 id

1

file_name

string

檔案名稱

a.txt

status

string

檔案狀態

uploading

exist

boolean

檔案是否存在

false

樣本

正常返回樣本

JSON格式

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

錯誤碼

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情