java - 如何在电报机器人(JAVA)中下载文件
问题描述
我想在我的电报机器人代码中下载一个文件,许多教程说我必须使用 getFile 方法,而我在 4.2 版本的电报 API 中找不到该方法,那么我如何将文件下载到主机 pc 中的特定目标?谢谢
解决方案
Assuming you are using TelegramBot SDK from rubenlagus (https://github.com/rubenlagus/TelegramBots), as I faced same issue. Below is my solution.
GetFile getFile = new GetFile().setFileId(fileId);
String filePath = execute(getFile).getFilePath();
File file = downloadFile(filePath, outputFile);
推荐阅读
- python - 如何在 5 秒后停止此循环?
- c# - 检查用户名是否已经在数据库中
- javascript - lit-html:连接字符串以使用 html``
- python - 如何从 javadoc 注释中删除 { 和 } 之间的 @link 标记及其内容?
- highcharts - Highchart 地图显示了一些已选择的状态,并具有选择其他状态的可行性
- javascript - 如何使用 fetch 发送数组?(Javascript)
- c# - 解释一些关于动态连接字符串的代码
- android - 在 genymotion 设备中运行时膨胀类 androidx.constraintlayout.widget.ConstraintLayout 时出错
- html - 如何摆脱自动填充html?
- dll-injection - 如何从我的 VSTS MSTest 管道中的另一个管道使用 VSTS 工件 DLL