Today I learned
How do I repost a video to a Telegram channel without uploading the file again?
My video job renders an MP4, sends it to me in a private chat, and exits. Hours later a different service (the website) has to post the same video to a channel, and by then the file is gone.
Keep the file_id from the first send and pass it instead of the file. Telegram reuses the upload, and the size limit for multipart uploads doesn't apply:
// 1. The job: upload once, keep the id
const res = await bot('sendVideo', form) // multipart with the MP4
const fileId = res.result.video.file_id // save it next to the record
// 2. Later, anywhere: no file, just the id
await bot('sendVideo', { chat_id: '@my_channel', video: fileId, caption })
Three rules I hit:
- A
file_idbelongs to the bot that got it. The service that reposts must use the same bot token. - Resend with the same method: a video id goes back through
sendVideo, notsendDocument. - Read
file_idfrom the API response. If you shell out to a send script, make it print the id (I print one JSON line), or you lose it.
I hit this while wiring my TIL Shorts pipeline: the Cloud Run job sends me the Short to review, and when it goes public on YouTube the site posts that same upload to the channel by file_id.