在 google 应用程序脚本中发送照片/上传 blob 文件到电报

sendphoto /upload blob file to telegram in google app script

我会使用 telegram API sendphoto 功能在 Google App Script 中发送照片消息。

照片是从chart.getAs('image/png')生成的Blob文件。 https://developers.google.com/apps-script/reference/charts/

在参考文献 https://core.telegram.org/bots/api#sendphoto 中,它说

Post the file using multipart/form-data in the usual way that files are uploaded via the browser

难道我不能用电报上传api?

如果可以,我可以使用下面的 google 应用程序脚本上传照片吗?

UrlFetchApp.fetch("https://api.telegram.org/botXXXXXXX/sendPhoto?chat_id=YYYYYYYY&photo=" + blob);

Telegram 只接受 link 图片或文件上传。 或许可以使用原始 blob 数据直接上传,而无需使用任何临时文件。