【发布时间】:2018-04-10 20:25:12
【问题描述】:
我在通过sendDocument 方法将文件上传到电报时遇到了一个奇怪的问题。我正在用python-telegram-bot 用python 编写一个机器人。我尝试向用户发送一个 ZIP 文件,并提供一个 URL 为document。
这是网址:http://telegram.someurl.tdl/32487352.zip
bot.send_document(
chat_id,
document=document,
filename=filename,
timeout=60)
据我所知,我的文件遵循 Telegram 给出的规则:http://telegram.someurl.tdl/32487352.zip
- 为 Telegram 提供 HTTP URL
http://telegram.someurl.tdl/32487352.zip
- 最大 20 MB
2.14 MB
- 正确的 MIME 类型
application/zip
- 通过 URL 发送目前仅适用于 gif、pdf 和 zip 文件
ZIP file
这些是标题:
Accept-Ranges →bytes
Connection →keep-alive
Content-Length →2247049
Content-Type →application/zip
Date →Sun, 29 Oct 2017 21:15:36 GMT
ETag →"59f5e6e6-224989"
Last-Modified →Sun, 29 Oct 2017 14:34:14 GMT
Server →nginx/1.10.3 (Ubuntu)
文件由 nginx (v1.10.3) 提供,配置简单。
server {
listen 80;
server_name telegram.someurl.tdl;
root /path/to/download_dir;
location / {
try_files $uri $uri/ =404;
}
}
其中/path/to/download_dir当然被替换为实际路径。
如标题所述,我得到的错误是这个:
{
"ok": false,
"error_code": 400,
"description": "Bad Request: wrong file identifier/HTTP URL specified"
}
还发送另一个我在网上找到的 ZIP 文件:http://techslides.com/demos/samples/sample.zip
我已经在寻找解决方案,例如。这个Telegram bot weird error : Bad Request: wrong file identifier/HTTP URL specified 和这个Why i get Wrong file identifier/HTTP URL specified error in telegram bot? 没有帮助。
希望大家能帮帮我。
【问题讨论】:
标签: python web telegram-bot