> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vmeg.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 生成预签名上传 URL

> 单文件上传**第 1 步**：获取预签名 PUT URL 与 `materialId`。把文件 PUT 到 `uploadUrl`，再调用[完成单文件上传](/zh/api-reference/app-synced/assets/materials/complete-upload)。如果返回了 `material`，说明素材库里已有同一文件，无需上传。除非用 `source.youtubeUrl` 创建任务，否则必须先上传。

上传按 `fileHash` 去重：上传网站素材库里已有的同一文件会直接返回已有素材，删除该素材时网站**我的资产**中也会一起消失。



## OpenAPI

````yaml /zh/api-reference/app-synced.json post /openapi/v1/app/assets/material/upload/gen-upload-url
openapi: 3.1.0
info:
  title: VMEG 开放 API（应用同源版）
  description: >-
    与独立版协议一致，但任务、素材、克隆音色都在你的 VMEG 网站账号里：任务出现在**我的任务**，可在编辑器继续编辑并重新导出。结果通过轮询 `GET
    /openapi/v1/app/tasks/detail` 获取（无
    Webhook）。见[独立版与应用同源版的区别](/zh/guides/app-synced/comparison)。


    文中链接的指南按独立版编写，步骤相同，把路径前缀 `/openapi/v1` 换成 `/openapi/v1/app` 即可。
  version: 1.0.0
servers:
  - url: https://api.vmeg.ai
    description: 生产环境
security:
  - apiKeyAuth: []
tags:
  - name: 媒体翻译
    x-group: 视频与音频翻译配音
    description: >-
      在与 vmeg.ai 相同的链路上翻译配音已上传的视频/音频或 YouTube
      链接。首轮即产出配音成片，任务同时出现在**我的任务**，可继续编辑并重新导出。结果请轮询[查询任务状态](/zh/api-reference/app-synced/tasks/get-task-detail)。
  - name: 声音克隆
    x-group: 声音克隆
    description: 用一段短录音克隆音色。音色保存到网站**我的音色**，返回 `cv_*`，可用于翻译配音任务。
  - name: 任务管理
    x-group: 任务状态与历史
    description: 列出、查看或删除你 VMEG 账号下的视频/音频翻译任务，包括在网站创建的任务。
  - name: 资产 - 素材
    x-group: 上传文件（素材）
    description: 上传并管理网站素材库（**我的资产**）里的文件。完成上传（单文件或分片）后，把 `materialId` 传给 create-async。
  - name: 资产 - 音色
    x-group: 音色（预设与克隆）
    description: 列出系统预设音色（`sv_*`），管理你的克隆音色（`cv_*`，与网站**我的音色**相同）。
paths:
  /openapi/v1/app/assets/material/upload/gen-upload-url:
    post:
      tags:
        - 资产 - 素材
      summary: 生成预签名上传 URL
      description: >-
        单文件上传**第 1 步**：获取预签名 PUT URL 与 `materialId`。把文件 PUT 到
        `uploadUrl`，再调用[完成单文件上传](/zh/api-reference/app-synced/assets/materials/complete-upload)。如果返回了
        `material`，说明素材库里已有同一文件，无需上传。除非用 `source.youtubeUrl` 创建任务，否则必须先上传。


        上传按 `fileHash` 去重：上传网站素材库里已有的同一文件会直接返回已有素材，删除该素材时网站**我的资产**中也会一起消失。
      operationId: appMaterialGenUploadUrl
      parameters:
        - $ref: '#/components/parameters/IdempotencyKeyRequired'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenApiMaterialFileHashRequest'
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenApiMaterialGenUploadUrlResponse'
components:
  parameters:
    IdempotencyKeyRequired:
      name: X-Idempotency-Key
      in: header
      required: true
      description: 创建任务或修改持久化数据的 `POST` 必填（最长 64 字符）。见 [幂等](/zh/guides/idempotency)。
      schema:
        type: string
        maxLength: 64
  schemas:
    OpenApiMaterialFileHashRequest:
      type: object
      required:
        - fileHash
        - fileName
      properties:
        fileHash:
          type: string
          description: 文件 MD5
        fileName:
          type: string
          description: 文件名（含扩展名）
    OpenApiMaterialGenUploadUrlResponse:
      allOf:
        - $ref: '#/components/schemas/OpenApiResponseBase'
        - type: object
          properties:
            data:
              $ref: '#/components/schemas/OpenApiMaterialGenUploadUrlData'
    OpenApiResponseBase:
      type: object
      properties:
        code:
          type: integer
          example: 200
          description: 业务码；200 表示成功
        message:
          type: string
          example: ''
          description: 当 `code` 非成功时的说明信息
      required:
        - code
    OpenApiMaterialGenUploadUrlData:
      type: object
      properties:
        uploadUrl:
          type: string
          description: 预签名 PUT URL；秒传时为空
        material:
          $ref: '#/components/schemas/OpenApiMaterialDto'
          description: 文件已存在（秒传）时返回
        materialId:
          type: string
          description: 本次上传的素材 ID。见 [素材](/zh/guides/app-synced/comparison)
    OpenApiMaterialDto:
      type: object
      properties:
        materialId:
          type: string
          description: 素材 ID。见 [素材](/zh/guides/app-synced/comparison)
        category:
          type: string
          example: video
          description: 素材类型
        name:
          type: string
          description: Display file name
        addressUrl:
          type: string
          description: 主文件 CDN URL
        thumbnailUrl:
          type: string
          description: 缩略图 CDN URL
        audioUrl:
          type: string
          description: 分离音轨 CDN URL
        resolution:
          type: string
          example: 1920x1080
          description: 视频分辨率（如适用，例如 `1920x1080`）
        mimeType:
          type: string
          description: 主文件的 MIME 类型
        fileHash:
          type: string
          description: 主文件 MD5
        filesize:
          type: integer
          format: int64
          description: 文件大小（字节）
        duration:
          type: integer
          format: int64
          description: 时长（毫秒）
        createTime:
          type: string
          description: 注册时间（ISO 8601）
        updateTime:
          type: string
          description: 最近更新时间（ISO 8601）
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      description: >-
        在 **`Authorization`** 请求头中传入 API Key（`Bearer <api_key>`）。见
        [鉴权](/zh/guides/authentication)。

````