Universal-Arduino-Telegram-Bot icon indicating copy to clipboard operation
Universal-Arduino-Telegram-Bot copied to clipboard

send .txt file

Open droidprova opened this issue 4 years ago • 8 comments

Hello and thank you for the precious work you do. I noticed that you are working on updating this fantastic library. I have a request for you: is it possible to add a function that allows you to send a .txt file stored on an SD card? Exactly how it happens for photos? Thanks so much

droidprova avatar Jun 18 '20 07:06 droidprova

Will take a look if I have time.

witnessmenow avatar Jun 24 '20 10:06 witnessmenow

Hello and thank you for the precious work you do. I noticed that you are working on updating this fantastic library. I have a request for you: is it possible to add a function that allows you to send a .txt file stored on an SD card? Exactly how it happens for photos? Thanks so much

You can also use telegramOta example for send files into spiffs.

solcer avatar Sep 13 '20 13:09 solcer

Hi, could you please see an example. Thank you

droidprova avatar Sep 14 '20 06:09 droidprova

Hi, could you please see an example. Thank you Hi,

You can use telegramOTA.ino code for esp32. it is under the examples/Untested inc Upgrade/ESP32/telegram OTA/ folder.

if you send files with "write spiffs" caption, the code will write your file into to spiffs. If you send spiffs.bin file with "update spiffs" caption: it writes spiffs image to spiffs section. If you send firmware.bin file with "update firmware" caption: it updates firmware.

Besst

solcer avatar Sep 14 '20 12:09 solcer

Hi! To send a .txt file stored on an SD card by this library need some changes: Make a copy of sendPhotoByBinary and change string: String response = sendMultipartFormDataToTelegram("sendPhoto", "photo", "img.jpg", to String response = sendMultipartFormDataToTelegram("sendDocument", "document", "file.txt", I tried it, it works and sends me a "file.txt". Also i change "file.txt" to new input variable String& fileName.

PoriadnyyOleg avatar Jan 23 '21 16:01 PoriadnyyOleg

Hi! To send a .txt file stored on an SD card by this library need some changes: Make a copy of sendPhotoByBinary and change string: String response = sendMultipartFormDataToTelegram("sendPhoto", "photo", "img.jpg", to String response = sendMultipartFormDataToTelegram("sendDocument", "document", "file.txt", I tried it, it works and sends me a "file.txt". Also i change "file.txt" to new input variable String& fileName. can you please elaborate on this. If possible please give me the full code

akil1947 avatar Jun 02 '23 13:06 akil1947

add in .h : String sendDocumentByBinary( const String& chat_id, const String& contentType, int fileSize, MoreDataAvailable moreDataAvailableCallback, GetNextByte getNextByteCallback, GetNextBuffer getNextBufferCallback, GetNextBufferLen getNextBufferLenCallback, const String& fileName);

add in .cpp: String UniversalTelegramBot::sendDocumentByBinary( const String& chat_id, const String& contentType, int fileSize, MoreDataAvailable moreDataAvailableCallback, GetNextByte getNextByteCallback, GetNextBuffer getNextBufferCallback, GetNextBufferLen getNextBufferLenCallback, const String& fileName) {

#ifdef TELEGRAM_DEBUG
Serial.println(F("sendDocument: SEND Document")); #endif

String response = sendMultipartFormDataToTelegram("sendDocument", "document", fileName, contentType, chat_id, fileSize, moreDataAvailableCallback, getNextByteCallback, getNextBufferCallback, getNextBufferLenCallback);

#ifdef TELEGRAM_DEBUG
Serial.println(response); #endif

return response; }

PoriadnyyOleg avatar Jun 02 '23 17:06 PoriadnyyOleg

@PoriadnyyOleg thank you so much for your help!

akil1947 avatar Jun 04 '23 18:06 akil1947