Skip to content
Open
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ Here is a sample config file:
"shared": true,
"params": {
"Token": "<OBTAIN_TOKEN_FROM_BOTFATHER>",
"ChatID": "<INSERT_CHAT_ID_HERE>"
"ChatID": "<INSERT_CHAT_ID_HERE>",
"MaxPartSize": "51380224",
"TempDir": "/tmp"
}
}
]
Expand Down
38 changes: 37 additions & 1 deletion fs/telegram/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Bots are not allowed to contact users. You need to make the first contact from t
Please note about `shared` flag. If it's `true` then bot instance will be shared between all connections.
If it's `false` then each user (or even each ftp connection) will have own bot instance and it can lead to telegram bot flood protection.

`MaxPartSize` (optional) sets the maximum size in bytes for each part when uploading large files. Files exceeding this size are automatically split into multiple parts. Default is `51380224` (49 MB). Telegram's upload limit is 50 MB.

`TempDir` (optional) sets the directory used to store temporary multipart chunks before upload. If omitted, the system temp directory is used.

```json
{
"version": 1,
Expand All @@ -34,7 +38,9 @@ If it's `false` then each user (or even each ftp connection) will have own bot i
"pass": "my_secure_password",
"params": {
"Token": "<YOUR_BOT_TOKEN>",
"ChatID": "<YOUR_CHAT_ID>"
"ChatID": "<YOUR_CHAT_ID>",
"MaxPartSize": "51380224",
"TempDir": "/tmp"
}

}
Expand All @@ -45,3 +51,33 @@ If it's `false` then each user (or even each ftp connection) will have own bot i
}
}
```

## Reassembling multipart files

When a file exceeds `MaxPartSize`, it is uploaded as numbered parts (`filename.part1ofN`, `filename.part2ofN`, …).
Download all parts into the same directory, then reassemble them with one of the commands below.

**Linux / macOS**

```bash
# Reassemble every *.tar.gz split in the current directory
for base in $(ls *.part1of* | sed 's/\.part1of.*//'); do
ls "${base}.part"*of* | sort -t'f' -k2 -n | xargs cat > "${base}"
echo "Reassembled: ${base}"
done
```

**Windows (PowerShell)**

```powershell
# Reassemble every *.tar.gz split in the current directory
Get-ChildItem '*.part1of*' | ForEach-Object {
$base = $_.Name -replace '\.part1of.*', ''
$out = $base
Get-ChildItem "${base}.part*of*" |
Sort-Object { [int]($_.Name -replace '.*\.part(\d+)of.*','$1') } |
ForEach-Object { Get-Content $_.FullName -AsByteStream } |
Set-Content -AsByteStream $out
Write-Host "Reassembled: $out"
}
```
4 changes: 3 additions & 1 deletion fs/telegram/example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"pass": "test",
"params": {
"Token": "123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789",
"ChatID": "123456789"
"ChatID": "123456789",
"MaxPartSize": "51380224",
"TempDir": "/tmp"
}

}
Expand Down
Loading