File size: 2,923 Bytes
3952353
 
 
 
 
 
 
 
 
 
18b952c
 
3952353
18b952c
 
 
3952353
18b952c
3952353
 
 
 
18b952c
3952353
18b952c
3952353
18b952c
3952353
 
 
 
 
 
 
18b952c
3952353
18b952c
3952353
 
 
 
18b952c
3952353
 
 
 
18b952c
3952353
 
 
18b952c
 
 
 
 
3952353
18b952c
3952353
 
 
18b952c
 
3952353
18b952c
3952353
18b952c
3952353
18b952c
 
 
 
3952353
18b952c
 
3952353
18b952c
3952353
18b952c
3952353
18b952c
 
3952353
18b952c
 
 
 
 
3952353
 
18b952c
3952353
18b952c
3952353
 
 
 
18b952c
3952353
18b952c
3952353
 
 
18b952c
3952353
 
 
18b952c
3952353
 
18b952c
3952353
18b952c
3952353
18b952c
18fc6cc
 
3952353
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
title: Telegram File Streamer
emoji: πŸš€
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
license: mit
---

# πŸš€ Telegram Multi-Part File Streamer

A high-performance file upload and streaming service that uses Telegram as a backend storage system. Capable of handling files up to **1TB** with zero-disk buffering.

## ✨ Features

- **🎯 Zero-Disk Buffering**: Direct streaming from HTTP to Telegram
- **πŸ“¦ Auto-Splitting**: Automatically splits large files into 2GB parts
- **⚑ Multi-Session Load Balancing**: Maximum bandwidth with session rotation
- **πŸ“‘ Range Request Support**: HTTP 206 for seeking in large files
- **πŸ”„ Parallel Downloads**: IDM and multi-threaded downloader compatible
- **πŸ’Ύ Low Memory**: Optimized for <512MB RAM usage

## πŸ”§ Required Secrets

This Space requires the following environment variables (add in Settings β†’ Repository secrets):

| Variable | Description | Example |
|----------|-------------|---------|
| `API_ID` | Telegram API ID | `12345678` |
| `API_HASH` | Telegram API Hash | `abc123def456...` |
| `BOT_TOKEN` | Bot Token from @BotFather | `1234567890:ABC...` |
| `MONGO_URI` | MongoDB connection string | `mongodb+srv://...` |
| `SESSION_STRINGS` | Session strings (optional) | `BQAB...,BQAC...` |

### How to Get Credentials:

**Telegram API (API_ID & API_HASH):**
1. Visit https://my.telegram.org/apps
2. Login and create application
3. Copy api_id and api_hash

**Bot Token:**
1. Search @BotFather on Telegram
2. Send `/newbot` command
3. Copy bot token

**MongoDB:**
- Free: MongoDB Atlas (https://www.mongodb.com/cloud/atlas)
- Create cluster β†’ Get connection string

## πŸ“‘ API Endpoints

### Upload File
```bash
POST /upload?filename=myfile.zip

curl -X POST "https://YOUR-SPACE.hf.space/upload?filename=file.zip" \
  -H "Content-Type: application/octet-stream" \
  --data-binary "@file.zip"
```

### Download File
```bash
GET /dl/{unique_id}

curl "https://YOUR-SPACE.hf.space/dl/{unique_id}" -o output.zip
```

### Get File Info
```bash
GET /info/{unique_id}
```

### Health Check
```bash
GET /health

curl "https://YOUR-SPACE.hf.space/health"
```

## πŸ“Š Performance

| Metric | Value |
|--------|-------|
| Max File Size | 1TB+ |
| Upload Speed | 10-15 MB/s per session |
| Download Speed | 50-100 MB/s |
| RAM Usage | <512MB constant |

## ⚠️ Important

- Ensure Telegram TOS compliance
- Files stored in your Telegram account
- Add multiple SESSION_STRINGS for better performance
- MongoDB IP whitelist: 0.0.0.0/0

## πŸ› Troubleshooting

**Build Failed:**
- Check all secrets are set correctly
- Verify MongoDB URI is valid

**FloodWait Errors:**
- Add more SESSION_STRINGS
- Use user sessions instead of bot only

**Out of Memory:**
- Upgrade Space hardware in Settings

## πŸ“„ License

MIT License

---

**Made with ❀️ for the community**

*Disclaimer: Use responsibly and comply with Telegram's Terms of Service.*