Pre-upload Files
GET /api/file/preUploadFile.do
Obtain a one-time upload address and credential, then transfer the actual file. Authenticate this request with Authorization: Bearer <access_token>.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
parent_id |
string | Destination folder ID. The source permits omission for a root upload; specify an authorized destination for enterprise workflows |
name |
string | Required file name |
file_id |
string | Existing file ID when uploading a new version; omit for a new file |
Response Example
This is a structural example. The address and credential are placeholders, not usable credentials.
{
"upload_token": "<UPLOAD_TOKEN>",
"url": "https://upload.example.com/<SERVER_RETURNED_PATH>",
"success": true,
"code": 0
}
| Field | Type | Description |
|---|---|---|
url |
string | Server-returned upload address; the source specifies one use within one hour |
upload_token |
string | Credential submitted with the actual upload |
success |
boolean | Whether pre-upload succeeded |
code |
integer | Business status code |
Step Two: Transfer File Content
POST multipart/form-data to the returned url, with binary field file and string field upload_token. Do not construct the upload path or send the file as JSON. Let the HTTP client generate the multipart boundary.
A successful transfer returns fileId, version, fileName, fileSize, success and code. Check both HTTP status and business result. A timeout does not prove failure; inspect existing files before retrying.
Security and Errors
- Validate the returned destination against the configured service or storage hosts. Use HTTPS in production; stop and investigate an unexpected address.
- Keep tokens and full temporary URLs out of public logs. Do not attach unrelated credentials to a dynamic upload host.
- Request a new address after expiration or use. Actual validity and fields depend on the deployed API.
- See Get Token and File API.