---
id: "en/api-get-api-file-preuploadfile-do"
title: "Pre-upload files"
language: "en"
description: "GET /api/file/preUploadFile.do: Pre-upload file interface description, including path, method, parameters and return information."
canonical_url: "https://www.babel.cc/public/babelwiki/en/api-get-api-file-preuploadfile-do.html"
markdown_url: "https://www.babel.cc/public/babelwiki/ai/en/api-get-api-file-preuploadfile-do.md"
alternates: {"en": "https://www.babel.cc/public/babelwiki/ai/en/api-get-api-file-preuploadfile-do.md", "zh": "https://www.babel.cc/public/babelwiki/ai/zh/api-get-api-file-preuploadfile-do.md"}
reading_note: "文档记录不等于当前部署能力；以实际版本、授权模块与配置为准。保留原文的可选、限制及待确认说明，勿补猜接口。 / Documentation is not a guarantee for every deployment. Preserve optional-module requirements, limitations and unresolved API contracts."
---

# 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.

```json
{
  "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](https://www.babel.cc/public/babelwiki/en/api-post-api-token-do.html) and [File API](https://www.babel.cc/public/babelwiki/en/developer-api-files.html).
