go-telegram / bot

Telegram Bot API Go framework
MIT License
507 stars 46 forks source link

Filename property of InputFileUpload is redundant #34

Closed xtianpu closed 1 year ago

xtianpu commented 1 year ago

Hello! I think the Filename property on InputFileUpload struct is redundant, it would be good if the lib could detect the filename by from passed parameter path. Like doing split of "/" then get the value of last index, continue by verify it was a correct file by checking the extension.

negasus commented 1 year ago

Hello. InputFileUpload has an io.Reader interface for getting the contents of a file. This approach makes it impossible to get the filename.

xtianpu commented 1 year ago

Oh, I just found out that we can send any random file_name and also filename is not really used or can be reused by the devs. Since if we want to reuse the uploaded file, we can provide the file_id not the filename. I don't know why Telegram put the optional file_name field to the request.

Anyway can the lib to do os.ReadFile so it we can just pass the file path instead?

negasus commented 1 year ago

I don't think adding a os.ReadFile function to the library is a good idea. Reading a file from disk is outside the scope of this library

xtianpu commented 1 year ago

Ah I see, thank you!