# 生成 CAR 文件

CAR 文件是发送给存储提供商的一个独立的单元。Swan Client 提供了四种不同的方式来生成 CAR 文件，且默认设置下生成的CAR 文件会被自动导入到 lotus 中。

**Graphsplit**

:bell: 此选项可以将源目录下的一个文件或整个目录中的文件拆分为输出目录中的一个或多个 CAR 文件。

```shell
swan-client generate-car graphsplit car --input-dir [input_files_dir] --out-dir [car_files_output_dir]

OPTIONS:
   --input-dir value, -i value       源文件所在的目录
   --out-dir value, -o value         CAR 文件将会生成在此目录下 (默认: "/tmp/tasks")
   --import                          是否导入 CAR 文件到 lotus (默认: true)
   --parallel value                  构建 ipld 节点时运行的线程数量 (默认: 5)
   --slice-size value, --size value  每个piece的字节 (默认: 17179869184)
   --parent-path                     基于整个文件夹生成 CAR 文件 (默认: true)
```

**此步骤后生成的文件：**

* `manifest.csv`: 由 `graphsplit API` 生成的一个元数据文件
* `car.json`: 包含源文件和 CAR 文件的信息
* `car.csv`: 包含源文件和 CAR 文件的信息
* `[dataCID].car`: 如果设置了 `--parent-path=true`，则 CAR 文件是基于整个目录构建，否则根据文件大小和 `--slice-size` 为每个文件创建独立的CAR文件

此功能应该感谢 FileDrive 团队，了解更多详情。

**Lotus API**

:bell: 此选项会将 `--input-dir` 中每个文件都生成一个单独的CAR文件。

:bell: 需要一个运行中的 **Lotus** 节点。

```shell
swan-client generate-car lotus --input-dir [input_files_dir] --out-dir [car_files_output_dir]

OPTIONS:
   --input-dir value, -i value       源文件所在的目录
   --out-dir value, -o value         CAR 文件将会生成在此目录下 (默认: "/tmp/tasks")
   --import                          是否导入 CAR 文件到 lotus (默认: true)
```

**此步骤后生成的文件：**

* `car.json`: 包含源文件和 CAR 文件的信息
* `car.csv`: 包含源文件和 CAR 文件的信息
* `[source-file-name].car`: 每个源文件都有一个关联的 CAR 文件

**IPFS API**

:bell: 此选项将使用 IPFS API 将源目录下的文件合并到输出目录中的一个 CAR 文件中。

:bell: 需要一个运行中的 **IPFS** 节点。

```shell
swan-client generate-car ipfs --input-dir [input_files_dir] --out-dir [car_file_output_dir]

OPTIONS:
   --input-dir value, -i value       源文件所在的目录
   --out-dir value, -o value         CAR 文件将会生成在此目录下 (默认: "/tmp/tasks")
   --import                          是否导入 CAR 文件到 lotus (默认: true)
```

**此步骤后生成的文件：**

* `car.json`: 包含 CAR 文件的信息
* `car.csv`: 包含 CAR 文件的信息
* `[dataCID].car`: 源文件将被合并到此 CAR 文件

**ipfs-car**

:bell: **需要** `ipfs-car` 包: `sudo npm install -g ipfs-car`

:bell: 此选项将使用 `ipfs-car` 命令将源目录下的文件合并到输出目录中的一个 CAR 文件。

```shell
swan-client generate-car ipfs-car --input-dir [input_files_dir] --out-dir [car_file_output_dir]

OPTIONS:
   --input-dir value, -i value       源文件所在的目录
   --out-dir value, -o value         CAR 文件将会生成在此目录下 (默认: "/tmp/tasks")
   --import                          是否导入 CAR 文件到 lotus (默认: true)
```

**此步骤后生成的文件：**

* `car.json`: 包含 CAR 文件的信息
* `car.csv`: 包含 CAR 文件的信息
* `[source-files-dir-name].car`: 源文件将会被合并到 CAR 文件中


---

# Agent Instructions: 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:

```
GET https://docs-cn.filswan.com/swan-client/chuang-jian-ren-wu-liu-cheng/filecoin-jiao-yi-fa-song-yin-qing/sheng-cheng-car-wen-jian.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
