Kibotos
API 参考HTTP 端点

/v1/files

本页说明 node 数据面的 /v1/files。参数名与限制由 Kibotos 实现它所用的常量生成,说明保持英文。

Reads and writes the content of one file in the guest. Directories and metadata go through FilesystemService, and paths follow its rules: absolute, or relative to the home directory of the identity user selects.

凭证

  • Authorization: Bearer <credential>, with the credential of a data-plane session that has the scope the method needs.

方法

方法权限范围说明
GETDATA_PLANE_SCOPE_FILE_READReads the file. A single Range: bytes=… range, including one that counts from the end such as bytes=-500, answers 206 with Content-Range; several ranges answer 400 and a range beyond the file answers 416. If-Range is forwarded to the guest unchanged. The response carries Content-Type, Content-Length, Content-Range, Accept-Ranges, ETag and Last-Modified; ETag is an opaque string.
PUTDATA_PLANE_SCOPE_FILE_WRITEWrites the file from the request body. 200 means the file is on storage; the body reports what was written. A read-only directory answers 403 and an exhausted file system or quota answers 413, also for root; neither is retryable, and a file already at the path stays unchanged.

查询参数

参数方法必填说明
pathGET, PUT是The file: an absolute path in the guest, or a path relative to the home directory of user.
userGET, PUTThe guest identity the request runs as: empty for the account the Template declares, that account's name, or root.
modePUTThe permissions of a new file, in octal with permission bits only, such as 0644. Defaults to 0600.
create_onlyPUTtrue or 1 fails the request when the file exists; false, 0 or no value overwrites it.

Any other parameter, a parameter given twice, an invalid value, and mode or create_only on GET answer 400 (invalid_argument) before the request reaches the guest.

消息体

PUT result

The body of a successful PUT. Compare the size and digest with what you sent.

字段类型说明
pathstringThe cleaned absolute path written.
size_bytesnumberThe number of bytes written.
sha256stringThe SHA-256 digest of the bytes written, in lowercase hexadecimal.

Error body

The body of every error response, with Content-Type: application/json.

字段类型说明
codestringThe name of the Connect error code, such as not_found.
detailobjectThe ErrorDetail of the error in protobuf JSON, with the field names of the proto file.

状态码

HTTP 状态码Connect 错误码
400invalid_argument
401unauthenticated
403permission_denied
404not_found
405unimplemented
409already_exists, failed_precondition, aborted
413resource_exhausted
499canceled
500unknown, out_of_range, internal, data_loss
503unavailable
504deadline_exceeded

An unsatisfiable range answers 416 with Content-Range: bytes */<size>.

A request whose body stalls for longer than the progress timeout answers 408.

Methods other than GET and PUT answer 405.

限制

限制值说明
Bytes per request1 GiBThe bytes of one GET response or PUT body. Read a larger file with several Range requests.
Rate64 MiB/sThe transfer rate of one request.
Burst1 MiBThe bytes one request may transfer above the rate at once.
Progress timeout5 sHow long the caller may send no request body, or read no response, before the node ends the request. Time the node spends waiting for the guest does not count.

另见

本页内容