Skip to main content

查询文件信息及下载地址

调用条件、权限、请求字段、响应字段与错误处理。

请求与权限

GET https://openapi.qwenwork.ai/v1/drive/files 鉴权:Authorization: Bearer <access_token>;使用用户 OAuth 授权获得的访问令牌。 所需业务 Scope:drive.file.read 契约声明的授权方式:组织授权(organization)、个人授权(personal) Scope 需由平台为应用开通;用户须有相应业务权限,目标资源须在其可访问范围内。个人/组织方式是否为该应用开放,以控制台实际配置为准。

功能与限制

查询文件信息及下载地址。签名 URL 具有有效期,不记录或分享,不携带平台 Token 访问 OSS。上游继续校验用户和 Scope。

查询参数

参数类型必填说明及约束
file_idstring否与 path 必须二选一,业务服务执行互斥校验。
格式:"uuid"
pathstring否个人文件空间绝对路径,与 file_id 二选一。
最短长度:1
匹配规则:"^/"

请求体

公开契约未声明请求体。不要自行添加身份字段或未经声明的业务字段。

成功响应

保持各业务接口原始响应结构,不统一添加 code/msg/data 包装。

HTTP 200

文件信息 响应类型:application/json
字段类型必含说明及约束
created_atstring是—
download_urlstring否—
file_idstring是—
is_directoryboolean是—
mime_typestring是—
modified_atstring是—
namestring是—
pathstring是—
sizeinteger否—

错误响应

HTTP说明及处理
400业务或网关错误
401业务或网关错误
403业务或网关错误
404业务或网关错误
409业务或网关错误
410业务或网关错误
413业务或网关错误
429业务或网关错误
500业务或网关错误
502业务或网关错误
503业务或网关错误
504业务或网关错误
保留响应中的请求 ID 和错误字段用于排查。写操作超时或断线后可能已经生效,不能仅凭没有收到成功响应就自动重试。

完整字段契约

下方 JSON 包含本接口完整请求、响应、错误 Schema、嵌套约束和公开扩展定义,可复制用于核对。未声明的成功示例不作推测。
{
  "components": {
    "schemas": {
      "Error": {
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      },
      "File": {
        "properties": {
          "created_at": {
            "type": "string"
          },
          "download_url": {
            "type": "string"
          },
          "file_id": {
            "type": "string"
          },
          "is_directory": {
            "type": "boolean"
          },
          "mime_type": {
            "type": "string"
          },
          "modified_at": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "size": {
            "type": "integer"
          }
        },
        "required": [
          "file_id",
          "path",
          "name",
          "is_directory",
          "mime_type",
          "created_at",
          "modified_at"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "OpenPlatformBearer": {
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "openapi": "3.1.0",
  "paths": {
    "/v1/drive/files": {
      "get": {
        "description": "查询文件信息及下载地址。签名 URL 具有有效期,不记录或分享,不携带平台 Token 访问 OSS。上游继续校验用户和 Scope。",
        "operationId": "drive-get-files",
        "parameters": [
          {
            "description": "与 path 必须二选一,业务服务执行互斥校验。",
            "in": "query",
            "name": "file_id",
            "required": false,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "个人文件空间绝对路径,与 file_id 二选一。",
            "in": "query",
            "name": "path",
            "required": false,
            "schema": {
              "minLength": 1,
              "pattern": "^/",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/File"
                }
              }
            },
            "description": "文件信息",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "data": {
                          "type": "null"
                        },
                        "msg": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "msg",
                        "data"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "业务或网关错误",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "data": {
                          "type": "null"
                        },
                        "msg": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "msg",
                        "data"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "业务或网关错误",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "data": {
                          "type": "null"
                        },
                        "msg": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "msg",
                        "data"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "业务或网关错误",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "data": {
                          "type": "null"
                        },
                        "msg": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "msg",
                        "data"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "业务或网关错误",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "data": {
                          "type": "null"
                        },
                        "msg": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "msg",
                        "data"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "业务或网关错误",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "410": {
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "data": {
                          "type": "null"
                        },
                        "msg": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "msg",
                        "data"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "业务或网关错误",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "data": {
                          "type": "null"
                        },
                        "msg": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "msg",
                        "data"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "业务或网关错误",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "data": {
                          "type": "null"
                        },
                        "msg": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "msg",
                        "data"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "业务或网关错误",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "data": {
                          "type": "null"
                        },
                        "msg": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "msg",
                        "data"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "业务或网关错误",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "data": {
                          "type": "null"
                        },
                        "msg": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "msg",
                        "data"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "业务或网关错误",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "data": {
                          "type": "null"
                        },
                        "msg": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "msg",
                        "data"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "业务或网关错误",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "504": {
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "data": {
                          "type": "null"
                        },
                        "msg": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "msg",
                        "data"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "业务或网关错误",
            "headers": {
              "X-Request-ID": {
                "description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "OpenPlatformBearer": []
          }
        ],
        "summary": "查询文件信息及下载地址",
        "tags": [
          "文件查询"
        ]
      }
    }
  },
  "info": {
    "title": "查询文件信息及下载地址",
    "version": "2026-11-24"
  },
  "servers": [
    {
      "url": "https://openapi.qwenwork.ai"
    }
  ]
}
返回 OpenAPI 总览。