> ## Documentation Index
> Fetch the complete documentation index at: https://docs.textin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# S3兼容服务

> 配置 S3 兼容的对象存储目的地，支持 AWS S3、MinIO 及各大云厂商

S3 兼容服务使用 AWS S3 SDK 接入，支持所有兼容 S3 协议的对象存储服务。将在配置的文件地址中写入 `json` 文件。

### 参数说明

| 参数           | 类型       | 必填 | 说明                      |
| ------------ | -------- | -- | ----------------------- |
| `type`       | `string` | 是  | 固定为 `"s3"`              |
| `endpoint`   | `string` | 是  | S3 服务端点 URL             |
| `access_key` | `string` | 是  | 访问密钥 ID（Access Key ID）  |
| `secret_key` | `string` | 是  | 访问密钥（Secret Access Key） |
| `bucket`     | `string` | 是  | 存储桶名称                   |
| `prefix`     | `string` | 否  | 对象前缀（文件夹路径），默认为空字符串     |
| `region`     | `string` | 否  | 区域名称，默认为 `"us-east-1"`  |

### 权限要求

配置可参考上文中 Source 的配置，需要注意的是，需要确保配置的访问凭证在上述权限的基础上包括 `PutObject` 权限，例如在使用阿里云OSS时，需要包括以下权限：

```
oss:HeadBucket
oss:ListObjects
oss:GetObject
oss:PutObject
```

### 通用配置示例

```python theme={null}
from xparse_client import S3Destination

destination = S3Destination(
    endpoint='https://your-s3-endpoint.com',
    access_key='your-access-key-id',
    secret_key='your-secret-access-key',
    bucket='your-bucket-name',
    prefix='output/',  # 可选，指定文件夹前缀
    region='us-east-1'    # 可选，默认为 us-east-1
)
```

### 支持的服务

xParse 支持以下 S3 兼容服务，点击查看具体配置指南：

* [MinIO](/pipeline/sources/minio) - 高性能对象存储服务
* [AWS S3](/pipeline/sources/aws-s3) - 亚马逊云对象存储
* [阿里云 OSS](/pipeline/sources/aliyun-oss) - 阿里云对象存储服务
* [腾讯云 COS](/pipeline/sources/tencent-cos) - 腾讯云对象存储
* [火山引擎 TOS](/pipeline/sources/volcengine-tos) - 火山引擎对象存储
* [华为云 OBS](/pipeline/sources/huawei-obs) - 华为云对象存储服务

### 输出文件格式

每个处理后的文件会生成一个对应的 JSON 文件，文件名格式为：`{原文件名}.json`

JSON 文件包含以下内容：

```json theme={null}
[
    {
        "element_id": "13a9939f23e485ca20a16c741658bcf64efd82309a6f0a8cf35679a65b2fd0dc",
        "type": "NarrativeText",
        "text": "文档内容...",
        "metadata": {
            "filename": "example.pdf",
            "filetype": "application/pdf",
            ...
        },
        "embeddings": [0.1, 0.2, 0.3, ...]
    }
]
```

### 使用示例

```python theme={null}
from xparse_client import S3Destination, Pipeline

destination = S3Destination(
    endpoint='https://s3.oss-cn-shanghai.aliyuncs.com',  # 阿里云 OSS 端点
    access_key='your-access-key-id',
    secret_key='your-secret-access-key',
    bucket='my-output-bucket',
    prefix='results/',  # 结果文件将保存在 results/ 文件夹下
    region='cn-shanghai'
)

# ... 其他配置

pipeline = Pipeline(
    source=source,
    destination=destination,
    # ...其他配置
)
pipeline.run()
```

运行后，处理结果会保存到配置的 S3 存储桶中，每个文件对应一个 JSON 结果文件。

### 适用场景

S3 兼容服务目的地适合以下场景：

* 需要将处理结果存储到云端对象存储服务
* 需要跨地域或跨团队共享处理结果
* 需要与云服务集成
* 需要高可用性和可扩展性的存储方案
