Spaces:
Sleeping
Sleeping
Download test_upload.bak from codebydante/BrodyFileStreamBot: direct link, hf CLI and curl.
- Browser
- Download file 765 Bytes
-
https://huggingface.co/spaces/codebydante/BrodyFileStreamBot/resolve/main/test_upload.bak
- Command line
-
hf download hf://spaces/codebydante/BrodyFileStreamBot/test_upload.bak
-
curl -L -o test_upload.bak https://huggingface.co/spaces/codebydante/BrodyFileStreamBot/resolve/main/test_upload.bak
765 Bytes
| package main | |
| import ( | |
| "context" | |
| "github.com/celestix/gotgproto/ext" | |
| "github.com/gotd/td/telegram/message" | |
| "github.com/gotd/td/telegram/uploader" | |
| "github.com/gotd/td/tg" | |
| ) | |
| func testUpload(ctx *ext.Context, replyTo int, fileBytes []byte, fileName string) error { | |
| u := uploader.NewUploader(ctx.Raw) | |
| file, err := u.FromBytes(ctx, fileName, fileBytes) | |
| if err != nil { | |
| return err | |
| } | |
| sender := message.NewSender(ctx.Raw) | |
| media := &tg.InputMediaUploadedDocument{ | |
| File: file, | |
| MimeType: "text/plain", | |
| Attributes: []tg.DocumentAttributeClass{ | |
| &tg.DocumentAttributeFilename{FileName: fileName}, | |
| }, | |
| } | |
| _, err = sender.To(ctx.EffectiveChat().AsInputPeer()).Reply(replyTo).Media(ctx, message.Media(media)) | |
| return err | |
| } | |