Telegram Bot File Storage

Persistent File Storage for Telegram Bots

Store and serve files from your Telegram bot with global CDN.

The Telegram Bot API is great at moving messages and terrible at being a file store. getFile returns a file_path that's valid for roughly an hour, so the thing you'd actually put in a database — a stable download URL — doesn't exist. What you get is a file_id, which is a reference, not a link, and it's bound to your specific bot token: rotate the token or migrate to a new bot and every saved file_id becomes dead weight.

On top of that, getFile downloads are capped at 20 MB and uploads at 50 MB, so anything chunky simply can't round-trip through the Bot API.

The durable pattern is to treat Telegram as the inbox and files.link as the warehouse. When a user sends a document or photo, download it once via the bot, push the bytes through the files.link three-call upload, and persist the permanent CDN URL against the user or chat id. That URL outlives token rotations, bot migrations, and the file_path expiry window, and serves from edge locations worldwide when you reference it elsewhere.

A python-telegram-bot handler:

python
async def handle_file(update, context):
    tg_file = await update.message.document.get_file()
    data = bytes(await tg_file.download_as_bytearray())
    name = update.message.document.file_name
    # 1) POST /v1/files/{folderId} -> { urls: [{ url, id }] }
    meta = api_post(f"/v1/files/{FOLDER}",
                    {"filesMetadata": [{"name": name}]})
    url, fid = meta["urls"][0]["url"], meta["urls"][0]["id"]
    requests.put(url, data=data)               # 2) PUT bytes
    api_post("/v1/files/confirm-upload", {"ids": [fid]})  # 3) confirm
    save_for_user(update.effective_user.id, cdn_url_for(fid))
    await update.message.reply_text("Saved permanently.")

The Authorization header is your raw API key. To send a stored file back, you don't re-upload bytes — hand Telegram the CDN URL directly: await context.bot.send_photo(chat_id, photo=cdn_url) or send_document(chat_id, document=cdn_url), and Telegram fetches it from the edge itself. For files larger than the 50 MB Bot API cap, reply with a CDN link instead of pushing bytes; the user taps it and the browser downloads from the nearest edge. For private files, mint a fresh signed URL (10-minute expiry) immediately before the send.

Benefits With No Complexity

Global CDN delivery

Your files are served from 450+ edge locations worldwide.

Edge-cached worldwide

Files are cached close to your users for fast delivery.

Signed-URL security

Private files stay protected with time-limited access.

What You Get

Unlimited files

Upload as many files as you need.

Unlimited storage

There is no storage limit.

Public + Private storage

Private files are fully secured.

CDN ready links

Upload directly to 450+ edge locations worldwide.

Prepaid credits

No subscription. Pay only for the storage and bandwidth you use.

More coming soon

We have plenty of features coming!

How files.link Works

1. Upload

Create a project and upload your first file.

2. Copy

Copy the CDN link.

3. Use Anywhere

Paste and enjoy the blazing speed.

Why Developers Choose files.link

A Better Way to Store & Deliver Files

Telegram Bot API FilesFirebase StorageBackblaze B2files.link
Durable URL (no ~1h file_path expiry)
Handles files over the 50 MB Bot API cap
Permanent CDN URLs
Global CDN delivery built in
Single REST API, no SDK / cloud project
Send stored file back by passing the URL

Calculate Your Needs

Storage

0GB

Egress

0GB

CDN Bandwidth

0GB
Total: $0.000/month

Start Telegram Bot Storage

  • Global CDN delivery
  • Edge-cached worldwide
  • Signed-URL security
  • Unlimited files
  • Unlimited storage
  • Public + Private storage
  • No subscription — prepaid credits keep spend predictable
Start Telegram Bot Storage

Frequently Asked Questions

Why not just store the Telegram file_id?
A file_id is a reference, not a URL. To make it downloadable you call getFile, which returns a file_path valid for about an hour, then you must call getFile again. file_ids are also tied to your bot token — rotate the token or switch bots and they break. Re-uploading the bytes to files.link gives a stable CDN URL with no second round-trip.
How do I store a user's document in python-telegram-bot?
In your handler, call get_file() on the document, download_as_bytearray(), then run the three-call upload: POST /v1/files/{folderId} for a presigned URL and id, PUT the bytes, POST /v1/files/confirm-upload with {ids:[id]}. Persist the returned CDN URL against the user id.
How do I send a stored file back through the bot?
Because files.link public URLs are direct links, pass them straight to Telegram: send_photo(chat_id, photo=cdn_url) or send_document(chat_id, document=cdn_url). Telegram fetches from the CDN itself. For private files, mint a fresh signed URL right before the send.
Can the bot serve files larger than 50 MB?
Not through sendDocument, but it can reply with a files.link CDN URL of any size. The user taps the link and downloads directly from the edge, bypassing the Bot API transfer limits entirely.
General Questions
Is there a subscription?
No. files.link uses prepaid credits, so storage, bandwidth, and API usage are deducted from your balance as you go. The app explains the payment step before uploads are enabled — no monthly subscription and no per-user fees.
What is files.link?
files.link is a developer-first file platform that makes it simple to store, secure, and deliver files globally. It provides signed URLs, public/private access, and an API-first design so you can integrate file delivery into any app without the usual complexity.
How does billing work?
files.link uses prepaid credits. As you use storage, bandwidth, and API requests, credits are deducted daily. When your balance runs low, we automatically recharge it using your saved card. If an auto-recharge doesn't go through, your files and links stay put — you simply update your payment method or top up manually to keep going. No monthly subscriptions — just simple usage-based pricing.
How secure is my data?
All files are encrypted at rest and in transit. You can use signed URLs for private files, control access with permissions, and rely on enterprise-grade infrastructure for data protection.

Related

files.link
Copyright © 2026
All rights reserved
ContactGuidesGlossaryStatusLegal