A library for getting files or images on arduino based boards (ESP mainly, maybe others)
MIT License
A library for getting files & images on arduino based boards (ESP mainly, maybe others)
Trying to make getting files (or images) as easy as possible while keeping it generic so it should hopefully work on most types of boards.
Expect changes, and if you see ways of making it better, please either raise an issue or raise a PR!
I have put a lot of effort into creating Arduino libraries that I hope people can make use of. If you enjoy my work, please consider becoming a Github sponsor!
WiFiClientSecure
WiFiClientSecure secured_client;
FileFetcher fileFetcher(secured_client);
// If HTTPS make sure to handle it
// Either set a cert, fingerprint or set insecure
uint8_t *fileFile; // pointer that the library will store the file at (uses malloc)
int fileSize; // library will update the size of the file
bool gotImage = fileFetcher.getFile(fileUrl, &fileFile, &fileSize);
if(gotImage){
// fileFile is now a pointer to memory that contains the file file
// fileSize is the size of the file
// Use it however you need to!
free(fileFile); // Make sure to free the memory!
}
fs::File f = SPIFFS.open("/img.png", "w+");
if (!f)
{
Serial.println("file open failed");
return -1;
}
bool gotImage = fileFetcher.getFile(fileUrl, &f);
// Make sure to close the file!
f.close();
// your image should now be in the file