Upload File
Through this interface, you can upload files to the Ace Data Cloud's CDN and obtain a publicly accessible URL. The uploaded files will be stored in Tencent Cloud COS (Object Storage) and distributed via CDN acceleration.
This interface requires authentication, for details please refer to Platform Token.
¶ Interface Description
- Request Method: POST
- Request URL:
https://platform.acedata.cloud/api/v1/files/ - Request Headers:
- authorization:
Bearer {token}
- authorization:
- Request Format:
multipart/form-data
¶ Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
file | Yes | The file to upload |
¶ CURL Request Example
curl -X POST \
-H "authorization: Bearer {token}" \
-F "file=@/path/to/image.png" \
"https://platform.acedata.cloud/api/v1/files/"
¶ Response Result Example
{
"url": "https://cdn.acedata.cloud/abc123def.png"
}
¶ Response Field Description
| Field | Type | Description |
|---|---|---|
url |
string | The CDN access URL of the uploaded file |
¶ Code Example
Python:
import requests
url = "https://platform.acedata.cloud/api/v1/files/"
headers = {
"authorization": "Bearer {token}"
}
with open("/path/to/image.png", "rb") as f:
files = {"file": ("image.png", f, "image/png")}
response = requests.post(url, headers=headers, files=files)
result = response.json()
print(f"File URL: {result['url']}")
