注意

本文档适用于 Ceph 开发版本。

对象操作

对象是存储数据和元数据的容器。容器可以包含许多对象,但对象名称必须唯一。此 API 允许客户端创建对象、设置访问控制和元数据、检索对象的数据和元数据以及删除对象。由于此 API 会请求特定用户帐户中的信息,除非容器或对象的访问控制被有意设为公开访问(即允许匿名请求),否则此 API 中的所有请求都必须经过身份验证。

创建/更新对象

要创建新对象,请使用 API 版本、帐户、容器名称和新对象的名称发起请求。您必须在容器上具有写入权限才能创建或更新对象。对象名称必须在容器内唯一。请求不是幂等的,因此如果您不使用唯一名称,请求将更新对象。但是,如果您在对象名称中使用伪分层语法,并且它位于不同的伪分层目录下,则可以使用它来区分具有相同名称的其他对象。您可以在请求中包含访问控制标头和元数据标头。PUT request with the API version, account, container name and the name of the new object. You must have write permission on the container to create or update an object. The object name must be unique within the container. The PUT对象内容的 MD5 哈希。推荐。

语法

PUT /{api version}/{account}/{container}/{object} HTTP/1.1
     Host: {fqdn}
     X-Auth-Token: {auth-token}

请求头

ETag

描述:

An MD5 hash of the object’s contents. Recommended.

类型:

字符串

必需:

Content-Type

描述:

对象包含的内容类型。

类型:

字符串

必需:

Transfer-Encoding

描述:

指示对象是否是较大聚合对象的一部分。

类型:

字符串

有效值:

chunked

必需:

复制对象

复制对象允许您创建对象的服务器端副本,因此您不必下载它并在另一个容器/名称下上传它。要将一个对象的内容复制到另一个对象,您可以发起一个请求或一个请求,其中包含 API 版本、帐户和容器名称。对于请求,在请求中使用目标容器和对象名称,并在请求头中使用源容器和对象。对于请求,在请求中使用源容器和对象,并在请求头中使用目标容器和对象。您必须在容器上具有写入权限才能复制对象。目标对象名称必须在容器内唯一。请求不是幂等的,因此如果您不使用唯一名称,请求将更新目标对象。但是,如果您在对象名称中使用伪分层语法,并且它位于不同的伪分层目录下,则可以使用它来区分具有相同名称的目标对象和源对象。您可以在请求中包含访问控制标头和元数据标头。PUT request or a COPY request with the API version, account, and the container name. For a PUT request, use the destination container and object name in the request, and the source container and object in the request header. For a Copy request, use the source container and object in the request, and the destination container and object in the request header. You must have write permission on the container to copy an object. The destination object name must be unique within the container. The request is not idempotent, so if you do not use a unique name, the request will update the destination object. However, you may use pseudo-hierarchical syntax in your object name to distinguish the destination object from the source object of the same name if it is under a different pseudo-hierarchical directory. You may include access control headers and metadata headers in the request.

语法

PUT /{api version}/{account}/{dest-container}/{dest-object} HTTP/1.1
X-Copy-From: {source-container}/{source-object}
Host: {fqdn}
X-Auth-Token: {auth-token}

或者,也可以:

COPY /{api version}/{account}/{source-container}/{source-object} HTTP/1.1
Destination: {dest-container}/{dest-object}

请求头

X-Copy-From

描述:

与请求一起使用,以定义源容器/对象路径。PUT与请求一起使用,以定义目标容器/对象路径。

类型:

字符串

必需:

是的,如果使用。PUT

Destination

描述:

与请求一起使用,以定义源容器/对象路径。COPY request to define the destination container/object path.

类型:

字符串

必需:

是的,如果使用。COPY

If-Modified-Since

描述:

仅在源对象的属性日期/时间之后修改时才复制。last_modified attribute.

类型:

日期

必需:

If-Unmodified-Since

描述:

仅在源对象的属性日期/时间之后未修改时才复制。last_modified attribute.

类型:

日期

必需:

Copy-If-Match

描述:

仅在请求中的 ETag 与源对象的 ETag 匹配时才复制。

类型:

ETag。

必需:

Copy-If-None-Match

描述:

仅在请求中的 ETag 与源对象的 ETag 不匹配时才复制。

类型:

ETag。

必需:

删除对象

要删除对象,请使用 API 版本、帐户、容器和对象名称发起请求。您必须在容器上具有写入权限才能删除其内的对象。成功删除对象后,您将能够重用对象名称。DELETE request with the API version, account, container and object name. You must have write permissions on the container to delete an object within it. Once you have successfully deleted the object, you will be able to reuse the object name.

语法

DELETE /{api version}/{account}/{container}/{object} HTTP/1.1
Host: {fqdn}
X-Auth-Token: {auth-token}

获取对象

要检索对象,请使用 API 版本、帐户、容器和对象名称发起请求。您必须在容器上具有读取权限才能检索其内的对象。GET request with the API version, account, container and object name. You must have read permissions on the container to retrieve an object within it.

语法

GET /{api version}/{account}/{container}/{object} HTTP/1.1
Host: {fqdn}
X-Auth-Token: {auth-token}

请求头

range

描述:

要检索对象内容的一个子集,您可以指定一个字节范围。

类型:

日期

必需:

If-Modified-Since

描述:

仅在源对象的属性日期/时间之后修改时才复制。last_modified attribute.

类型:

日期

必需:

If-Unmodified-Since

描述:

仅在源对象的属性日期/时间之后未修改时才复制。last_modified attribute.

类型:

日期

必需:

Copy-If-Match

描述:

仅在请求中的 ETag 与源对象的 ETag 匹配时才复制。

类型:

ETag。

必需:

Copy-If-None-Match

描述:

仅在请求中的 ETag 与源对象的 ETag 不匹配时才复制。

类型:

ETag。

必需:

响应头

Content-Range

描述:

对象内容子集的范围。仅在请求中指定了范围标头字段时才返回。

获取对象元数据

要检索对象的元数据,请使用 API 版本、帐户、容器和对象名称发起请求。您必须在容器上具有读取权限才能从容器内的对象检索元数据。此请求返回与对象本身的请求相同的标头信息,但不会返回对象的数据。HEAD request with the API version, account, container and object name. You must have read permissions on the container to retrieve metadata from an object within the container. This request returns the same header information as the request for the object itself, but it does not return the object’s data.

语法

HEAD /{api version}/{account}/{container}/{object} HTTP/1.1
Host: {fqdn}
X-Auth-Token: {auth-token}

添加/更新对象元数据

要向对象添加元数据,请使用 API 版本、帐户、容器和对象名称发起请求。您必须在父容器上具有写入权限才能添加或更新元数据。POST request with the API version, account, container and object name. You must have write permissions on the parent container to add or update metadata.

语法

POST /{api version}/{account}/{container}/{object} HTTP/1.1
Host: {fqdn}
X-Auth-Token: {auth-token}

请求头

X-Object-Meta-{key}

描述:

一个用户定义的元数据键,它接受任意字符串值。

类型:

字符串

必需:

由 Ceph 基金会带给您

Ceph 文档是一个社区资源,由非盈利的 Ceph 基金会资助和托管Ceph Foundation. 如果您想支持这一点和我们的其他工作,请考虑加入现在加入.