Universal-Arduino-Telegram-Bot
Universal-Arduino-Telegram-Bot copied to clipboard
Any chance of send image from spiffs?
Hi would be brilliant to have an example that allows you to send an image stored in spiffs..
Is this possible?
Cheers
Dans
Hi Dans, i had same Idea and here is the code for you....
readFile(SPIFFS, "/img.jpg");
void readFile(fs::FS &fs, const char * path){
Serial.printf("Reading file: %s\r\n", path);
file = fs.open(path);
if(!file || file.isDirectory()){
Serial.println("- failed to open file for reading");
return;
}
sent = bot.sendPhotoByBinary(chat_id, "image/jpeg", file.size(),
isMoreDataAvailable,
getNextByte);
if (sent) {
Serial.println("was successfully sent");
} else {
Serial.println("was not sent");
}
file.close();
}
If you are sending a static image that is not generated by the Arduino itself, you might consider hosting it somewhere like Imgur and then use sendPhotoByUrl
https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot/blob/master/examples/ESP8266/SendPhoto/PhotoFromURL/PhotoFromURL.ino
On Sat, 22 Jun 2019, 12:35 svenp, [email protected] wrote:
Hi Dans, i had same Idea and here is the code for you....
readFile(SPIFFS, "/img.jpg");
void readFile(fs::FS &fs, const char * path){ Serial.printf("Reading file: %s\r\n", path);
file = fs.open(path); if(!file || file.isDirectory()){ Serial.println("- failed to open file for reading"); return; }
sent = bot.sendPhotoByBinary(chat_id, "image/jpeg", file.size(), isMoreDataAvailable, getNextByte); if (sent) { Serial.println("was successfully sent"); } else { Serial.println("was not sent"); }file.close(); }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot/issues/83?email_source=notifications&email_token=AAL5PQSDTZFFUF2Z7TSK3ETP3YE7FA5CNFSM4FGTRZMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYKHPYY#issuecomment-504657891, or mute the thread https://github.com/notifications/unsubscribe-auth/AAL5PQUQR4ZBQP4ZLYM5KITP3YE7FANCNFSM4FGTRZMA .