Universal-Arduino-Telegram-Bot
Universal-Arduino-Telegram-Bot copied to clipboard
send .txt file
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
Will take a look if I have time.
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.
Hi, could you please see an example. Thank you
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
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.
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",
toString 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
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 thank you so much for your help!