Fixed #1667, Implementing multipart upload of large files for the Telegram-based file system#1668
Open
NabiKAZ wants to merge 8 commits intofclairamb:mainfrom
Open
Fixed #1667, Implementing multipart upload of large files for the Telegram-based file system#1668NabiKAZ wants to merge 8 commits intofclairamb:mainfrom
NabiKAZ wants to merge 8 commits intofclairamb:mainfrom
Conversation
…r the Telegram-based file system Signed-off-by: Nabi <nabikaz60@gmail.com>
There was a problem hiding this comment.
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
MaxPartSizeparsing 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 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, |
| var err error | ||
| basePath := filepath.Base(f.Path) | ||
|
|
||
| if isExtension(f.Path, imageExtensions) { |
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 on lines
+95
to
+97
| if parseErr != nil || parsed <= 0 { | ||
| return nil, fmt.Errorf("invalid MaxPartSize parameter: %v", parseErr) | ||
| } |
| 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 on lines
+228
to
+230
| linuxCmd := "cat " + strings.Join(partFilenames, " ") + " > " + originalName | ||
| winParts := strings.Join(partFilenames, "+") | ||
| winCmd := "copy /b " + winParts + " " + originalName |
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"+ |
| } | ||
| } | ||
| // Send join instructions after all parts are uploaded | ||
| f.sendJoinInstructions(basePath, partFilenames) |
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
More: #1667