> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/contributor/contributor-zh/nei-rong/file-system.md).

# 文件系统

Decentraland 协议中不同内容 API 的基础是分布式文件系统的实现。每个内容服务器都保存整个存储的一份副本，并将接收到的更新与其他实例同步。

上传到系统的文件是 **不可变的**。一旦部署，它们的标识符和内容都不会改变。它们只能以这样的方式更新：上传一个新版本，由应用程序选择使用它，而旧版本可以被丢弃。

你可以在……中试验文件 [练习](https://github.com/decentraland/docs/blob/main/contributor/content/practice/README.md) 部分使用可运行的代码来尝试快照。

### 文件标识符 <a href="#identifiers" id="identifiers"></a>

Decentraland 的文件系统组织为一个扁平索引（即没有自然的目录层次结构），其中每个文件都由一个唯一字符串标识。

标识符字符串以前缀 [base32](https://en.wikipedia.org/wiki/Base32) 编码的文件内容 SHA-256 哈希为前缀，使用 [IPFS CID v1](https://docs.ipfs.tech/concepts/content-addressing/) 算法。它们看起来像这样：

```
bafybeicgclohdfaccu2sqqkzrzuenjxzcry3m5vcb4mpxgucjl3oheq5tq
```

前几个字节中的前缀表示该标识符本身的编码、版本和哈希类型。

{% hint style="info" %}
由于历史原因，一些 API 将文件标识符称为 *hash* 而不是 *id*，但它们指的是同一件事。你也可能在旧内容中发现一些看起来稍有不同的旧版标识符。
{% endhint %}

在实践中，这些细节对于发现和下载内容并不是必需的。该协议的大多数客户端都可以把标识符当作不透明字符串来处理，而不会损失任何能力。

请注意，现代 CIDv1 标识符与 IPFS 兼容，同一文件会得到相同的 CID，因此可以将 IPFS 用作文件提供方。

### 所有权与持久性

除 [快照](https://github.com/decentraland/docs/blob/main/contributor/content/snapshots/README.md)之外，存储在网络中的文件都关联到一个 [实体](https://github.com/decentraland/docs/blob/main/contributor/content/entities/README.md) 由一个 Ethereum 账户拥有。只有所有者才被允许更新该实体及其相关文件。

协议要求内容服务器始终存储一个实体及其文件的最新版本，但可以根据各自的配置选择是否保留旧版本。

### 下载文件 <a href="#downloading" id="downloading"></a>

该 [`/contents/<fileId>`](https://decentraland.github.io/catalyst-api-specs/#tag/Content-Server/operation/getContentFile) 内容服务器的端点可用于下载任何文件。它们的标识符可在父级 [实体的](https://github.com/decentraland/docs/blob/main/contributor/content/entities/README.md)清单中找到。

### 上传文件

文件不会被单独上传。相反，它们被打包在实体内部，并在该实体部署到内容服务器时上传。

请参阅 [内容创建者文档](https://github.com/decentraland/docs/blob/main/creator/README.md) 了解更多详情。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.decentraland.org/contributor/contributor-zh/nei-rong/file-system.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
