Skip to content

Support uploading multiple files in a single request #354

@Syfaro

Description

@Syfaro

Certain methods (sendMediaGroup, editMessageMedia, anything that supports thumbnails) allow uploading multiple files. Currently, UploadFile is structured in such a way it can only accept a single file to upload:

telegram-bot-api/bot.go

Lines 151 to 159 in da98517

// UploadFile makes a request to the API with a file.
//
// Requires the parameter to hold the file not be in the params.
// File should be a string to a file path, a FileBytes struct,
// a FileReader struct, or a url.URL.
//
// Note that if your FileReader has a size set to -1, it will read
// the file into memory to calculate a size.
func (bot *BotAPI) UploadFile(endpoint string, params Params, fieldname string, file interface{}) (APIResponse, error) {

Therefore, there needs to be a change to support uploading multiple files. One blocking issue is that the underlying library used to send files without reading everything into memory, multipartstreamer, only accepts one file per request. A replacement would have to be created.

I would love to get feedback on the best way to implement this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions