Skip to content

Commit 0e67ab3

Browse files
committed
add: send file from Stream, closes #37
1 parent 505cd2c commit 0e67ab3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

telebot/utils.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import macros, httpclient, asyncdispatch, sam, strutils, types, options, logging, strtabs, random
22
from json import escapeJson
3+
from streams import Stream, readAll
34

45
randomize()
56

@@ -211,6 +212,9 @@ proc addData*(p: var MultipartData, name: string, content: auto, fileCheck = fal
211212
else:
212213
p.add(name, $content)
213214

215+
proc addData*(p: var MultipartData, name: string, content: Stream, fileName = "", contentType = "") {.inline.} =
216+
p.add(name, content.readAll(), fileName, contentType)
217+
214218
proc uploadInputMedia*(p: var MultipartData, m: InputMedia) =
215219
var name = "file_upload_" & $rand(high(int))
216220
if m.media.startsWith("file://"):

0 commit comments

Comments
 (0)