附件與檔案
建立新附件 (整合)
POST /api/attachments-upload/
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X POST "https://api.maiagent.ai/api/attachments-upload/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
-F "file=@example_file.pdf"
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
回應內容
狀態碼
說明
200
No response body
取得檔案上傳用的預簽署 URL (建立/取得)
POST /api/upload-presigned-url/
參數
參數名稱
必填
類型
說明
fieldName
❌
string
欄位名稱
filename
❌
string
檔案名稱
modelName
❌
string
模型名稱
請求內容
請求參數
欄位
類型
必填
說明
fileSize
integer
是
請求結構範例
{
"fileSize": integer
}
請求範例值
{
"fileSize": 123
}
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X POST "https://api.maiagent.ai/api/upload-presigned-url/?fieldName=example&filename=example&modelName=example" \
-H "Authorization: Api-Key YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"modelName": "request_string",
"fieldName": "request_string",
"filename": "request_string",
"fileSize": 123
}'
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
回應內容
狀態碼: 200
回應結構範例
{
"url": string (uri) // S3 儲存桶的 URL
"fields": object // 用於 POST 請求的表單字段
}
回應範例值
{
"url": "https://s3.example.com/bucket-name",
"fields": {
"key": "media/chat/attachment/filename.pdf",
"x-amz-algorithm": "AWS4-HMAC-SHA256",
"x-amz-credential": "AKIAXXXXXXXXXXXXXXXX/YYYYMMDD/region/s3/aws4_request",
"x-amz-date": "YYYYMMDDTHHMMSSZ",
"policy": "base64-encoded-policy-document",
"x-amz-signature": "generated-signature-hash"
}
}
Presigned 上傳附件
POST /api/attachments/
請求內容
請求參數
欄位
類型
必填
說明
type
object
否
filename
string
是
file
string (uri)
是
請求結構範例
{
"type"?: object // 非必填
"filename": string
"file": string (uri)
}
請求範例值
{
"type": null,
"filename": "request_string",
"file": "request_string"
}
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X POST "https://api.maiagent.ai/api/attachments/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": null,
"filename": "request_string",
"file": "request_string"
}'
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
回應內容
狀態碼: 201
回應結構範例
{
"id": string (uuid)
"type"?: object // 非必填
"filename": string
"file": string (uri)
}
回應範例值
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "response_string",
"file": "response_string"
}
建立對話附件
POST /api/conversations/{conversationPk}/attachments/
參數
參數名稱
必填
類型
說明
conversationPk
✅
string
請求內容
請求參數
欄位
類型
必填
說明
type
object
否
filename
string
是
file
string (uri)
是
conversation
string (uuid)
否
請求結構範例
{
"type"?: object // 非必填
"filename": string
"file": string (uri)
"conversation"?: string (uuid) // 非必填
}
請求範例值
{
"type": null,
"filename": "request_string",
"file": "request_string",
"conversation": "550e8400-e29b-41d4-a716-446655440000"
}
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X POST "https://api.maiagent.ai/api/conversations/{conversationPk}/attachments/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": null,
"filename": "request_string",
"file": "request_string",
"conversation": "550e8400-e29b-41d4-a716-446655440000"
}'
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
回應內容
狀態碼: 201
回應結構範例
{
"id": string (uuid)
"type"?: object // 非必填
"filename": string
"file": string (uri)
"conversation"?: string (uuid) // 非必填
}
回應範例值
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "response_string",
"file": "response_string",
"conversation": "550e8400-e29b-41d4-a716-446655440000"
}
Last updated
Was this helpful?