feat: support base64 file upload in rl_upload, clarify API docs
- rl_upload.dspy: use b64media2url to convert base64/local path to
public URL before calling vendor API
- docs/api_downapp.md:
- Clarify dapi Bearer Token auth flow (dapi middleware -> get_user/get_userorgid)
- Add base64 upload example for rl_upload
- Clarify rl_status URL is a temporary signed download link (12h),
asset is permanently stored on volcengine, permanent ref is vendor_asset_id
- Update overview with auth, upload, and key management sections
This commit is contained in:
parent
36be53699d
commit
1d05b7e36b
@ -3,9 +3,16 @@
|
||||
## 概述
|
||||
本文档说明下游应用如何调用 `reallife_asset` 模块接口,完成真人人像素材的认证、上传及状态查询。
|
||||
|
||||
**核心机制**:
|
||||
- 所有接口均通过 **Bearer Token** 认证,dapi 模块自动识别调用方身份,获取 `user_id` 和 `org_id`。
|
||||
- **调用方无需传递 `downapp_id`**,系统自动从认证上下文中获取用户和机构信息。
|
||||
**认证机制**:
|
||||
- 所有接口通过 **dapi Bearer Token** 认证:客户端在请求头中携带 `Authorization: Bearer <apikey>`
|
||||
- dapi 中间件自动识别调用方身份,设置 `get_user()`(用户ID)和 `get_userorgid()`(机构ID)
|
||||
- **调用方无需传递身份参数**,系统自动从认证上下文中获取
|
||||
|
||||
**素材上传**:
|
||||
- `source_url` 支持两种格式:公网 URL 或 `data:` base64 编码
|
||||
- base64 格式由系统通过 `b64media2url` 自动转为公网地址,无需客户自行托管文件
|
||||
|
||||
**供应商密钥管理**:
|
||||
- 供应商密钥(AK/SK)由营运人员在后台集中维护,调用方无需在请求中传递。
|
||||
|
||||
## 业务流程
|
||||
@ -72,13 +79,13 @@ Content-Type: application/json
|
||||
| 参数 | 必填 | 说明 |
|
||||
|------|------|------|
|
||||
| `vendor_group_id` | 是 | 认证成功后获得的供应商组合 ID(通过 `rl_query_groups` 查询) |
|
||||
| `source_url` | 是 | 素材的公网可访问 URL |
|
||||
| `source_url` | 是 | 素材的公网 URL **或** `data:` 格式的 base64 编码(系统自动转为公网地址) |
|
||||
| `asset_type` | 否 | 素材类型:`Image` (默认) 或 `Video` |
|
||||
| `name` | 否 | 素材名称 |
|
||||
|
||||
> `org_id` 由 Bearer Token 自动获取,无需传递。
|
||||
|
||||
### 请求示例
|
||||
### 请求示例(公网 URL)
|
||||
```http
|
||||
POST /reallife_asset/api/rl_upload.dspy
|
||||
Authorization: Bearer <your_api_key>
|
||||
@ -92,6 +99,20 @@ Content-Type: application/json
|
||||
}
|
||||
```
|
||||
|
||||
### 请求示例(base64 直接上传)
|
||||
```http
|
||||
POST /reallife_asset/api/rl_upload.dspy
|
||||
Authorization: Bearer <your_api_key>
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"vendor_group_id": "volc-asset-group-xxx",
|
||||
"source_url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...",
|
||||
"asset_type": "Image",
|
||||
"name": "模特B"
|
||||
}
|
||||
```
|
||||
|
||||
### 返回示例
|
||||
**成功**:
|
||||
```json
|
||||
@ -136,10 +157,12 @@ Content-Type: application/json
|
||||
{
|
||||
"success": true,
|
||||
"status": "Active",
|
||||
"url": "https://... (素材下载链接,12小时有效)"
|
||||
"url": "https://... (临时下载链接,12小时有效)"
|
||||
}
|
||||
```
|
||||
|
||||
> **说明**:火山引擎的素材**永久存储**在其服务器上。`url` 是临时签名下载链接,过期后可通过再次调用 `rl_status` 获取新链接。素材的永久引用为上传时返回的 `vendor_asset_id`。
|
||||
|
||||
---
|
||||
|
||||
## 4. 查询已认证的组合列表
|
||||
|
||||
@ -6,5 +6,11 @@ name = params_kw.get('name', '')
|
||||
if not vendor_group_id or not source_url:
|
||||
return {"success": False, "message": "参数缺失"}
|
||||
|
||||
# If source_url is base64 data or local path, convert to public URL
|
||||
if source_url.startswith('data:') or (not source_url.startswith('http') and len(source_url) < 8000):
|
||||
source_url = await b64media2url(request, source_url)
|
||||
if not source_url:
|
||||
return {"success": False, "message": "素材文件转换失败"}
|
||||
|
||||
result = await rl_upload_user((await get_userorgid()) or '0', vendor_group_id, source_url, asset_type, name, (await get_user()))
|
||||
return result
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user