Upload Workspace Logo or Icon¶
POST /api/v1/workspace/{workspace_uuid}/upload_logo_image
Overview¶
Upload a Logo or site icon for the workspace specified by the path parameter. On success, saves the resource for the specified language and target filename.
Before Calling and Usage Steps¶
- Obtain the target workspace UUID from the Workspace List. Prepare an External API signing account with write permissions and a png or ico file no larger than 5 MiB.
- Choose the target filename and language, sign the request according to the multipart example, and upload it. Uploading again with the same workspace, filename, and language replaces the file.
- Use Get Logo URL to verify that the resource is accessible.
Replace wksp_example in the example with the actual UUID. Before uploading, verify the site and workspace identifiers. When using an icon, also replace the target filename and local file with favicon.ico or another actual .ico file; the upload API does not convert image formats.
The example depends on requests; install this library in the execution environment first. Set DF_EXTERNAL_ENDPOINT to the target External API address, and DF_EXTERNAL_ACCESS_KEY and DF_EXTERNAL_SECRET_KEY to the AK/SK pair assigned by the administrator. Do not write real credentials into the documentation or commit them to a repository. Replace the local logo.png, target workspace UUID, and Query parameters with actual values.
Path Parameters¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| workspace_uuid | string | Y | Workspace UUID Example: wksp_exampleHow to obtain or specify: Copy content.data[*].uuid from the workspace list response. |
Request Headers¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| X-Df-SVersion | string | Signature version. The following example uses v20240417. Example: v20240417How to obtain or specify: Enter it exactly as shown in the example; it must correspond to the signing algorithm. |
|
| X-Df-Access-Key | string | Y | Request AK information Example: <access-key>How to obtain or specify: Assigned by the External API administrator. |
| X-Df-Signature | string | Y | Signature information Example: <hex-signature>How to obtain or specify: Refer to the multipart example below; use the Secret Key to sign the concatenated text of POST, nonce, the original path and query string, timestamp, and an empty string. |
| X-Df-Timestamp | string | Y | Request timestamp Example: 1785456000How to obtain or specify: Enter the current Unix time in seconds at call time, for example by running date +%s. |
| X-Df-Nonce | string | Y | Temporary code generated for the request Example: b53b47e12e514616ad8cb1f17cb66dceHow to obtain or specify: Generate a new random value for each request, for example uuid.uuid4().hex. |
Query Parameters¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| filename | string | Filename Allowed values: ['logo.png', 'favicon.ico'] Example: logo.pngHow to obtain or specify: Choose logo.png or favicon.ico; if omitted, defaults to logo.png. |
|
| language | string | Language Allowed values: ['zh', 'en', 'zh-hant', 'id', 'ja', 'ko'] Example: zhHow to obtain or specify: Choose the language to apply; if omitted, defaults to zh. |
File Parameters (multipart/form-data)¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| file | file | Y | System logo and related files Maximum size per file: 5M Maximum number of files: 1 Allowed file extensions: ['png', 'ico'] Example: logo.pngHow to obtain or specify: Select the local png or ico file to upload. |
Additional Parameter Notes¶
Use the file field of multipart/form-data to upload one file. png or ico is allowed, with a maximum size of 5 MiB; the server saves it under the filename specified in the request.
If filename is omitted, logo.png is used. If language is omitted, zh is used. After saving, use the "Get Image Related Resources" API to query the URL.
The following example uses v20240417. This upload route parses the form first; the body part of the string to sign uses an empty string and preserves one space after the timestamp. Use the same path, query parameters, nonce, and timestamp in the same request.
Request Example¶
import hashlib
import hmac
import os
import time
import uuid
import requests
endpoint = os.environ["DF_EXTERNAL_ENDPOINT"].rstrip("/")
full_path = "/api/v1/workspace/wksp_example/upload_logo_image?filename=logo.png&language=zh"
timestamp = str(int(time.time()))
nonce = uuid.uuid4().hex
to_sign = " ".join(("POST", nonce, full_path, timestamp, ""))
signature = hmac.new(os.environ["DF_EXTERNAL_SECRET_KEY"].encode(), to_sign.encode(), hashlib.sha256).hexdigest()
headers = {
"X-Df-Access-Key": os.environ["DF_EXTERNAL_ACCESS_KEY"],
"X-Df-Signature": signature,
"X-Df-Timestamp": timestamp,
"X-Df-Nonce": nonce,
"X-Df-SVersion": "v20240417",
}
try:
with open("logo.png", "rb") as file:
response = requests.post(endpoint + full_path, headers=headers, files={"file": ("logo.png", file, "image/png")}, timeout=30)
except requests.RequestException:
print("请求结果未知,请先查询资源URL和实际文件,确认后再决定是否重传覆盖。")
raise SystemExit(1)
print("HTTP", response.status_code, response.text) # The error body contains errorCode, message, and traceId.
if not response.ok:
raise SystemExit(1)
Response¶
HTTP 200, application/json. Uploading again with the same workspace, target filename, and language overwrites the file.
| Field | Type | Description |
|---|---|---|
| content | boolean | Returns true when the save succeeds. |
{
"code": 200,
"content": true,
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-EXAMPLE"
}
Error Response¶
For authentication, rate limiting, and common request errors, see Common Error Definitions.
| HTTP Status | errorCode | Trigger Condition | Message or Response Description | Handling |
|---|---|---|---|---|
| 406 | ft.UploadFailed | The request does not contain any uploaded file. | No file was uploaded. | Upload a file via multipart/form-data. |
| 406 | ft.ParameterValidationFailed | The file field name, extension, count, or size does not meet requirements, or a Query parameter is not one of the allowed values. | The message indicates the invalid field or rule. | Check file, png/ico, the 5 MiB per-file limit, and the allowed values for filename/language. |
| 500 | ft.InternalServerError | Static resource directory creation, file saving, or another unhandled exception. | Internal error | Verify the permissions and available space of the resource storage directory; first query the current Logo or icon URL and actual file status, then decide whether to re-upload and overwrite, and retain traceId. |