Skip to content

Fixed #1667, Implementing multipart upload of large files for the Telegram-based file system#1668

Open
NabiKAZ wants to merge 8 commits intofclairamb:mainfrom
NabiKAZ:telegram-multipart
Open

Fixed #1667, Implementing multipart upload of large files for the Telegram-based file system#1668
NabiKAZ wants to merge 8 commits intofclairamb:mainfrom
NabiKAZ:telegram-multipart

Conversation

@NabiKAZ
Copy link
Copy Markdown

@NabiKAZ NabiKAZ commented May 3, 2026

More: #1667

…r the Telegram-based file system

Signed-off-by: Nabi <nabikaz60@gmail.com>
Copilot AI review requested due to automatic review settings May 3, 2026 12:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds multipart upload support to the Telegram filesystem backend so files larger than Telegram’s per-upload limit can be split and sent in smaller pieces. It extends the backend configuration with a MaxPartSize setting and updates the Telegram-specific docs/examples to show how the new behavior is configured.

Changes:

  • Added MaxPartSize parsing and storage in the Telegram backend, with a default of 49 MiB.
  • Updated File.Close() to split oversized uploads into numbered parts and send a follow-up message with reassembly instructions.
  • Documented the new configuration parameter in the Telegram README, example config, and top-level README.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
fs/telegram/telegram.go Implements multipart upload logic, configurable part sizing, per-part sending, and merge-instructions messaging.
fs/telegram/example.conf Adds MaxPartSize to the Telegram example configuration.
fs/telegram/README.md Documents the optional MaxPartSize parameter and updates the Telegram config example.
README.md Updates the top-level sample config to include MaxPartSize for Telegram access.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread fs/telegram/telegram.go Outdated
Comment on lines +232 to +239
msg := fmt.Sprintf(
"📦 File: %s\n📊 Total parts: %d\n\n"+
"To join parts after downloading:\n\n"+
"Linux/Mac:\n"+
"```\n%s\n```\n\n"+
"Windows:\n"+
"```\n%s\n```",
originalName, len(partFilenames), linuxCmd, winCmd,
Comment thread fs/telegram/telegram.go Outdated
var err error
basePath := filepath.Base(f.Path)

if isExtension(f.Path, imageExtensions) {
Comment thread fs/telegram/telegram.go Outdated
Comment on lines +91 to +97
// Parse MaxPartSize param, default to defaultMaxPartSize if not set or invalid
var maxPartSize int64 = defaultMaxPartSize
if partSizeStr := access.Params["MaxPartSize"]; partSizeStr != "" {
parsed, parseErr := strconv.ParseInt(partSizeStr, 10, 64)
if parseErr != nil || parsed <= 0 {
return nil, fmt.Errorf("invalid MaxPartSize parameter: %v", parseErr)
}
Comment thread fs/telegram/telegram.go Outdated
Comment on lines +95 to +97
if parseErr != nil || parsed <= 0 {
return nil, fmt.Errorf("invalid MaxPartSize parameter: %v", parseErr)
}
Comment thread fs/telegram/telegram.go Outdated
audio := tele.Audio{File: tele.FromReader(bytes.NewReader(data)), Caption: caption}
_, err = f.Fs.Bot.Send(&chat, &audio)
} else if isExtension(f.Path, textExtensions) && len(f.Content) < 4096 {
} else if isExtension(f.Path, textExtensions) && len(data) < 4096 {
Comment thread fs/telegram/telegram.go Outdated
Comment on lines +228 to +230
linuxCmd := "cat " + strings.Join(partFilenames, " ") + " > " + originalName
winParts := strings.Join(partFilenames, "+")
winCmd := "copy /b " + winParts + " " + originalName
Comment thread fs/telegram/telegram.go Outdated
Comment on lines +232 to +236
msg := fmt.Sprintf(
"📦 File: %s\n📊 Total parts: %d\n\n"+
"To join parts after downloading:\n\n"+
"Linux/Mac:\n"+
"```\n%s\n```\n\n"+
Comment thread fs/telegram/telegram.go Outdated
}
}
// Send join instructions after all parts are uploaded
f.sendJoinInstructions(basePath, partFilenames)
NabiKAZ added 7 commits May 3, 2026 17:27
…y large files to Telegram.

Signed-off-by: Nabi <nabikaz60@gmail.com>
… multipart upload support

Signed-off-by: Nabi <nabikaz60@gmail.com>
…rable multipart spool location

Signed-off-by: Nabi <nabikaz60@gmail.com>
…ransient upload failures

Signed-off-by: Nabi <nabikaz60@gmail.com>
…after upload

Signed-off-by: Nabi <nabikaz60@gmail.com>
…multipart uploads

Signed-off-by: Nabi <nabikaz60@gmail.com>
…ructions message; add README reassembly guide

Signed-off-by: Nabi <nabikaz60@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants