> ## 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.

# 阿里云 OSS

> 配置阿里云 OSS 对象存储数据源

## 阿里云 OSS

阿里云 OSS（Object Storage Service）兼容 S3 协议，可以使用 S3 SDK 接入。

### 如何获取鉴权参数

1. 登录 [阿里云控制台](https://home.console.aliyun.com/)
2. 进入 OSS 服务，创建存储桶（Bucket）
   ![创建Bucket](https://static.textin.com/docs/images/pipeline/oss-bucket-create.png)
3. 获取访问密钥：
   * 进入"访问控制 RAM" → "用户" → 创建用户或使用现有用户
     ![创建用户](https://static.textin.com/docs/images/pipeline/oss-user-create.png)
   * 为用户创建 AccessKey，获取 `AccessKey ID` 和 `AccessKey Secret`
     ![创建AccessKey](https://static.textin.com/docs/images/pipeline/oss-create-accesskey.png)
   * 为用户授予 OSS 读取权限，至少包括：
     * `oss:HeadBucket`：检查存储桶是否存在
     * `oss:ListObjects`：列出存储桶中的对象
     * `oss:GetObject`：获取对象内容
       ![创建权限策略](https://static.textin.com/docs/images/pipeline/oss-user-create-auth.png)
       ![授予权限](https://static.textin.com/docs/images/pipeline/oss-user-authorize.png)
4. 获取 OSS 端点：
   * 在存储桶概览页查看"Endpoint（地域节点）"
   * 格式：`https://s3.oss-{region}.aliyuncs.com`（S3 兼容端点）或 `https://oss-{region}.aliyuncs.com`
   * 例如：`https://s3.oss-cn-shanghai.aliyuncs.com` 或 `https://oss-cn-hangzhou.aliyuncs.com`
     ![获取Endpoint](https://static.textin.com/docs/images/pipeline/oss-get-endpoint.png)

### 配置示例

```python theme={null}
source = S3Source(
    endpoint='https://s3.oss-cn-shanghai.aliyuncs.com',  # 使用 S3 兼容端点
    access_key='your-access-key-id',
    secret_key='your-secret-access-key',
    bucket='your-bucket-name',
    prefix='documents/',  # 可选
    region='cn-shanghai'
)
```

### 使用示例

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

source = S3Source(
    endpoint='https://s3.oss-cn-shanghai.aliyuncs.com',
    access_key='your-access-key-id',
    secret_key='your-secret-access-key',
    bucket='my-documents',
    prefix='pdfs/',
    region='cn-shanghai'
)

# ... 其他配置

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

### 参考文档

* [阿里云 OSS S3 兼容性说明](https://help.aliyun.com/zh/oss/developer-reference/compatibility-with-amazon-s3)
