上传会员 KYC 文件到 Zinfra 私有存储
代会员调用 · 必带
x-on-behalf-of
需 x-idempotency-key
代会员调用。请求体直接放单个文件的原始字节;支持 JPEG、PNG、WebP与 PDF,单文件最大 8 MB。服务端不信任客户端声明的 Content-Type,会按文件魔数识别真实类型。
返回的 file_url 属于 x-on-behalf-of 指定会员的私有 KYC 目录。把它放进后续 POST /v1/kyc/applications 的profile.identity_photos.front/back/handheld。不要把外部 S3 URL 或 base64直接写进 KYC profile。
文件不可匿名访问,只能由该会员或具备 KYC 审核权限的 Zinfra 管理员读取。
请求头
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
x-idempotency-key |
string | 必填 | |
x-on-behalf-of |
string | 必填 | 会员的 external_member_id 或 mem_<uuid>。 |
请求体
这个 operation 还没有在 spec 里声明请求体字段。
响应
201文件已写入该会员的私有 R2 目录
{
"file_url": "https://api.zinfra.dev/kyc/file/member-uuid/file-uuid.jpg"
}400
member_context_required · kyc_upload_invalid · kyc_upload_too_large409
idempotency_key_reused · idempotency_in_progress429
rate_limited请求
curl -X POST 'https://api.zinfra.vip/v1/kyc/files' \
-H 'x-auth-token: Bearer $TOKEN' \
-H 'x-on-behalf-of: $MEMBER_ID' \
-H 'x-idempotency-key: $IDEMPOTENCY_KEY'const res = await fetch("https://api.zinfra.vip/v1/kyc/files", {
method: "POST",
headers: {
"x-auth-token": "Bearer $TOKEN",
"x-on-behalf-of": "$MEMBER_ID",
"x-idempotency-key": "$IDEMPOTENCY_KEY",
},
});
// 金额按字符串读,别让它变成 number
const data = await res.json();import requests
res = requests.post(
"https://api.zinfra.vip/v1/kyc/files",
headers={
"x-auth-token": "Bearer $TOKEN",
"x-on-behalf-of": "$MEMBER_ID",
"x-idempotency-key": "$IDEMPOTENCY_KEY",
},
)
# 金额用 Decimal(str(...)),不要 float
data = res.json()req, _ := http.NewRequest("POST", "https://api.zinfra.vip/v1/kyc/files",
nil)
req.Header.Set("x-auth-token", "Bearer $TOKEN")
req.Header.Set("x-on-behalf-of", "$MEMBER_ID")
req.Header.Set("x-idempotency-key", "$IDEMPOTENCY_KEY")
res, err := http.DefaultClient.Do(req)
// 金额字段用 string 接,不要 float64HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.zinfra.vip/v1/kyc/files"))
.header("x-auth-token", "Bearer $TOKEN")
.header("x-on-behalf-of", "$MEMBER_ID")
.header("x-idempotency-key", "$IDEMPOTENCY_KEY")
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
// 金额字段用 String / BigDecimal,不要 double$ch = curl_init('https://api.zinfra.vip/v1/kyc/files');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'x-auth-token: Bearer $TOKEN',
'x-on-behalf-of: $MEMBER_ID',
'x-idempotency-key: $IDEMPOTENCY_KEY',
],
]);
$res = curl_exec($ch);
// 金额用 bcmath / 字符串,不要 floatval
201
{
"file_url": "https://api.zinfra.dev/kyc/file/member-uuid/file-uuid.jpg"
}