public class File extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
CreateFileResp |
create(CreateFileReq req)
上传文件,调用该接口将本地文件上传至开放平台,支持上传音频、视频、文档等文件类型。
|
CreateFileResp |
create(CreateFileReq req,
RequestOptions reqOptions)
上传文件,调用该接口将本地文件上传至开放平台,支持上传音频、视频、文档等文件类型。
|
GetFileResp |
get(GetFileReq req)
下载文件,通过已上传文件的 Key 下载文件。
|
GetFileResp |
get(GetFileReq req,
RequestOptions reqOptions)
下载文件,通过已上传文件的 Key 下载文件。
|
public File(Config config)
public CreateFileResp create(CreateFileReq req, RequestOptions reqOptions) throws Exception
## 前提条件;;应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)。;;## 使用限制;;文件大小不得超过 30 MB,且不允许上传空文件。 ;
官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=create&project=im&resource=file&version=v1 ;
Exceptionpublic CreateFileResp create(CreateFileReq req) throws Exception
## 前提条件;;应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)。;;## 使用限制;;文件大小不得超过 30 MB,且不允许上传空文件。 ;
官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=create&project=im&resource=file&version=v1 ;
Exceptionpublic GetFileResp get(GetFileReq req, RequestOptions reqOptions) throws Exception
## 前提条件;;应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)。;;## 使用限制;;- 只能下载由当前机器人上传的文件。;- 下载的资源大小不能超过 100 MB。 ;- 该接口仅适用于通过文件的 Key 下载文件。如果你需要下载用户发送消息内的资源文件,可使用[获取消息中的资源文件](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message-resource/get)接口。;- 如果需要 Content-Disposition header,发起请求时需要在 header 中设置 Content-Type 为 application/json。 ;
官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=get&project=im&resource=file&version=v1 ;
Exceptionpublic GetFileResp get(GetFileReq req) throws Exception
## 前提条件;;应用需要开启[机器人能力](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)。;;## 使用限制;;- 只能下载由当前机器人上传的文件。;- 下载的资源大小不能超过 100 MB。 ;- 该接口仅适用于通过文件的 Key 下载文件。如果你需要下载用户发送消息内的资源文件,可使用[获取消息中的资源文件](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message-resource/get)接口。;- 如果需要 Content-Disposition header,发起请求时需要在 header 中设置 Content-Type 为 application/json。 ;
官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=get&project=im&resource=file&version=v1 ;
ExceptionCopyright © 2026. All rights reserved.