Open danbicks opened 6 years ago
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
On Sat, 22 Jun 2019, 12:35 svenp, notifications@github.com 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 .
Hi would be brilliant to have an example that allows you to send an image stored in spiffs..
Is this possible?
Cheers
Dans