Upload A File
curl --request POST \
--url https://files.uqpaytech.com/api/v1/files/upload \
--header 'Content-Type: multipart/form-data' \
--header 'x-auth-token: <api-key>' \
--header 'x-idempotency-key: <x-idempotency-key>' \
--form file='@example-file'import requests
url = "https://files.uqpaytech.com/api/v1/files/upload"
files = { "file": ("example-file", open("example-file", "rb")) }
headers = {
"x-idempotency-key": "<x-idempotency-key>",
"x-auth-token": "<api-key>"
}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
const options = {
method: 'POST',
headers: {'x-idempotency-key': '<x-idempotency-key>', 'x-auth-token': '<api-key>'}
};
options.body = form;
fetch('https://files.uqpaytech.com/api/v1/files/upload', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://files.uqpaytech.com/api/v1/files/upload",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"x-auth-token: <api-key>",
"x-idempotency-key: <x-idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://files.uqpaytech.com/api/v1/files/upload"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-idempotency-key", "<x-idempotency-key>")
req.Header.Add("x-auth-token", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://files.uqpaytech.com/api/v1/files/upload")
.header("x-idempotency-key", "<x-idempotency-key>")
.header("x-auth-token", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://files.uqpaytech.com/api/v1/files/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-idempotency-key"] = '<x-idempotency-key>'
request["x-auth-token"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"create_time": "2024-08-22T17:12:58+08:00",
"file_id": "b3d9d2d5-4c12-4946-a09d-953e82sed2b0",
"file_name": "example.png",
"file_type": "png",
"size": 123456,
"notes": "This is a note"
}File Service
Upload A File
向 UQPAY 上传文件。上传文件的最大大小为 20MB。支持的文件类型包括 jpeg、png、jpg、doc、docx、pdf。上传文件后,API 会返回一个 file_id。在我们的其他端点中,可按需将该文件 ID 作为 attachments 对象的一部分进行引用。
POST
/
v1
/
files
/
upload
Upload A File
curl --request POST \
--url https://files.uqpaytech.com/api/v1/files/upload \
--header 'Content-Type: multipart/form-data' \
--header 'x-auth-token: <api-key>' \
--header 'x-idempotency-key: <x-idempotency-key>' \
--form file='@example-file'import requests
url = "https://files.uqpaytech.com/api/v1/files/upload"
files = { "file": ("example-file", open("example-file", "rb")) }
headers = {
"x-idempotency-key": "<x-idempotency-key>",
"x-auth-token": "<api-key>"
}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
const options = {
method: 'POST',
headers: {'x-idempotency-key': '<x-idempotency-key>', 'x-auth-token': '<api-key>'}
};
options.body = form;
fetch('https://files.uqpaytech.com/api/v1/files/upload', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://files.uqpaytech.com/api/v1/files/upload",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"x-auth-token: <api-key>",
"x-idempotency-key: <x-idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://files.uqpaytech.com/api/v1/files/upload"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-idempotency-key", "<x-idempotency-key>")
req.Header.Add("x-auth-token", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://files.uqpaytech.com/api/v1/files/upload")
.header("x-idempotency-key", "<x-idempotency-key>")
.header("x-auth-token", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://files.uqpaytech.com/api/v1/files/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-idempotency-key"] = '<x-idempotency-key>'
request["x-auth-token"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"create_time": "2024-08-22T17:12:58+08:00",
"file_id": "b3d9d2d5-4c12-4946-a09d-953e82sed2b0",
"file_name": "example.png",
"file_type": "png",
"size": 123456,
"notes": "This is a note"
}授权
用于请求 API 的 Token。
请求头
用于保持操作幂等性的唯一标识符(UUID),确保同一操作的重复执行不会产生意外影响或重复结果。在出现网络错误、重试或失败时,它有助于保持数据一致性。
查询参数
所上传文件的备注,最大长度为 50 个字符。
Maximum string length:
50请求体
multipart/form-data
响应
200 - application/json
OK——文件上传成功。
文件上传的时间戳。
示例:
"2024-08-22T17:12:58+08:00"
所上传文件的唯一标识符。在其他 API 调用中使用该 ID 来引用此文件。
示例:
"b3d9d2d5-4c12-4946-a09d-953e82sed2b0"
所上传文件的原始名称(含扩展名)。
示例:
"example.png"
文件扩展名类型(例如 png、pdf、docx)。
示例:
"png"
文件大小,单位为字节。
示例:
123456
与该文件关联的可选备注。
示例:
"This is a note"
⌘I

