---
title: 建立檔案上傳 | RunAPI
description: 上傳一個本機檔案、遠端 HTTPS URL 或 base64 來源，並取得臨時 URL。
url: https://runapi.ai/zh-TW/docs/api/files/create.md
canonical: https://runapi.ai/zh-TW/docs/api/files/create
locale: zh-TW
---

> HTML 版本: https://runapi.ai/zh-TW/docs/api/files/create
> 代理程式網站索引: https://runapi.ai/llms.txt

# 建立檔案上傳

上傳一個本機檔案、遠端 HTTPS URL 或 base64 來源，並取得臨時 URL。

## 端點

POST /api/v1/files

基礎 URL: https://runapi.ai

API 版本: v1

身分驗證: Authorization: Bearer YOUR_API_KEY

## 請求

僅在列出的請求位置中傳送值。

### application/json - Base64 source

```json
{
  "file_name": {
    "description": "所建立分段上傳的選用檔案名稱。",
    "required": false,
    "type": "string"
  },
  "source": {
    "description": "Base64 編碼的來源位元組。",
    "properties": {
      "data": {
        "description": "Base64 資料",
        "required": true,
        "type": "string"
      },
      "type": {
        "description": "選取 base64 來源表示方式。",
        "required": true,
        "type": "string"
      }
    },
    "required": true,
    "type": "object"
  }
}
```

### application/json - URL source

```json
{
  "file_name": {
    "description": "所建立分段上傳的選用檔案名稱。",
    "required": false,
    "type": "string"
  },
  "source": {
    "description": "遠端 HTTPS 來源，用於下載。",
    "properties": {
      "type": {
        "description": "選取 URL 來源表示方式。",
        "required": true,
        "type": "string"
      },
      "url": {
        "description": "用於下載的公開 HTTPS URL。",
        "format": "uri",
        "required": true,
        "type": "string"
      }
    },
    "required": true,
    "type": "object"
  }
}
```

### multipart/form-data

```json
{
  "file": {
    "description": "要上傳的本機檔案位元組。",
    "format": "binary",
    "required": true,
    "type": "string"
  },
  "file_name": {
    "description": "所建立分段上傳的選用檔案名稱。",
    "required": false,
    "type": "string"
  }
}
```

## 成功回應

HTTP 201 - POST /api/v1/files

```json
{
  "created_at": "2026-07-27T10:00:00.000Z",
  "expires_at": "2026-07-27T11:00:00.000Z",
  "file_name": "mask.png",
  "mime_type": "image/png",
  "size_bytes": 204800,
  "url": "https://file.runapi.ai/temp/user-uploads/mask.png"
}
```

## 錯誤回應 (401)

HTTP 401

### 回應綱要

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "Authentication required"
}
```

## 錯誤回應 (403)

HTTP 403

### 回應綱要

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "Standard API key required"
}
```

## 錯誤回應 (400)

HTTP 400

### 回應綱要

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "Only HTTPS URLs are allowed"
}
```

## 錯誤回應 (408)

HTTP 408

### 回應綱要

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "Download timeout"
}
```

## 錯誤回應 (413)

HTTP 413

### 回應綱要

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "File size exceeds the maximum allowed size"
}
```

## 錯誤回應 (415)

HTTP 415

### 回應綱要

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "This content type is not supported"
}
```

## 錯誤回應 (422)

HTTP 422

### 回應綱要

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "File upload failed. Please try again."
}
```

## 錯誤回應 (429)

HTTP 429

### 回應綱要

```json
{
  "properties": {
    "error": {
      "description": "人類可讀的錯誤訊息。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### 回應範例

```json
{
  "error": "Too many file uploads for this account. Please retry later."
}
```

## cURL 範例



### curl

```curl
curl -X POST https://runapi.ai/api/v1/files \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"source":{"type":"url","url":"https://cdn.runapi.ai/public/samples/mask.png"},"file_name":"mask.png"}'
```

## 相關參考資料

- [檔案](https://runapi.ai/zh-TW/docs/api/files.md)
- [檔案上傳物件](https://runapi.ai/zh-TW/docs/api/files/object.md)

---

## RunAPI 的更多內容

- [首頁](https://runapi.ai/zh-TW/.md)
- [模型目錄](https://runapi.ai/zh-TW/models.md)
- [價格](https://runapi.ai/zh-TW/pricing.md)
- [提供商](https://runapi.ai/zh-TW/models)
- [文件](https://runapi.ai/zh-TW/docs/guides)
- [SDK](https://runapi.ai/zh-TW/sdk.md)
- [CLI](https://runapi.ai/zh-TW/cli.md)
- [MCP Server](https://runapi.ai/zh-TW/mcp.md)
- [Claude Code 與 Cursor](https://runapi.ai/zh-TW/claude-code-vs-cursor.md)
- [Cursor API 設定](https://runapi.ai/zh-TW/cursor-api-setup.md)
- [RunAPI 與 OpenRouter](https://runapi.ai/zh-TW/openrouter-alternative.md)
- [企業版](https://runapi.ai/zh-TW/contact.md)
- [聯絡我們](https://runapi.ai/zh-TW/contact.md)
- [服務條款](https://runapi.ai/zh-TW/terms.md)
- [隱私權](https://runapi.ai/zh-TW/privacy.md)
- [代理程式網站索引](https://runapi.ai/llms.txt)

聯絡我們: contact@runapi.ai

## 結構化資料

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-TW",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-TW",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/zh-TW/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-TW",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-TW",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/zh-TWicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-TW",
    "@type": "TechArticle",
    "headline": "建立檔案上傳",
    "description": "上傳一個本機檔案、遠端 HTTPS URL 或 base64 來源，並取得臨時 URL。",
    "url": "https://runapi.ai/zh-TW/docs/api/files/create",
    "mainEntityOfPage": "https://runapi.ai/zh-TW/docs/api/files/create"
  }
]
```
