@@ -222,6 +222,30 @@ class Request
222222 'getMe ' ,
223223 ];
224224
225+ /**
226+ * Available fields for InputFile helper
227+ *
228+ * This is basically the list of all fields that allow InputFile objects
229+ * for which input can be simplified by providing local path directly as string.
230+ *
231+ * @var array
232+ */
233+ private static $ input_file_fields = [
234+ 'setWebhook ' => ['certificate ' ],
235+ 'sendPhoto ' => ['photo ' ],
236+ 'sendAudio ' => ['audio ' , 'thumb ' ],
237+ 'sendDocument ' => ['document ' , 'thumb ' ],
238+ 'sendVideo ' => ['video ' , 'thumb ' ],
239+ 'sendAnimation ' => ['animation ' , 'thumb ' ],
240+ 'sendVoice ' => ['voice ' , 'thumb ' ],
241+ 'sendVideoNote ' => ['video_note ' , 'thumb ' ],
242+ 'setChatPhoto ' => ['photo ' ],
243+ 'sendSticker ' => ['sticker ' ],
244+ 'uploadStickerFile ' => ['png_sticker ' ],
245+ 'createNewStickerSet ' => ['png_sticker ' ],
246+ 'addStickerToSet ' => ['png_sticker ' ],
247+ ];
248+
225249 /**
226250 * Initialize
227251 *
@@ -327,6 +351,7 @@ public static function generateGeneralFakeServerResponse(array $data = [])
327351 * @param array $data
328352 *
329353 * @return array
354+ * @throws TelegramException
330355 */
331356 private static function setUpRequestParams (array $ data )
332357 {
@@ -337,6 +362,10 @@ private static function setUpRequestParams(array $data)
337362 if ($ key === 'media ' ) {
338363 // Magical media input helper.
339364 $ item = self ::mediaInputHelper ($ item , $ has_resource , $ multipart );
365+ } elseif (array_key_exists (self ::$ current_action , self ::$ input_file_fields ) && in_array ($ key , self ::$ input_file_fields [self ::$ current_action ], true )) {
366+ if (is_string ($ item ) && file_exists ($ item )) {
367+ $ item = new Stream (self ::encodeFile ($ item ));
368+ }
340369 } elseif (is_array ($ item )) {
341370 // Convert any nested arrays into JSON strings.
342371 $ item = json_encode ($ item );
0 commit comments