ImgurUploader
ImgurUploader copied to clipboard
🖼️ imgur.com 📤 image/video uploader library for ESP32
ImgurUploader
imgur.com image/video upload library for ESP32
❓ What is it?
This library will let you upload images or videos to imgur.com using WiFi. It can read from a file (SD, SD_MMC, SPIFFS) or from a byte array. This library is heavily inspired from the Arduino Imgur library https://github.com/tinkerlog/Imgur
It has been totally rewritten to fit the ESP32's WiFiClientSecure requirements, extended to different mime types and sources, and finally adapted to imgur's API v3.
Big thanks to @tinkerlog for the inspiration.
🏗️ Install
For the lazy: search for "imgurUploader" in the Arduino library manager and click "install".

For the brave: download the the latest release from this repository and use the import option from the Arduino IDE sketch menu.

🛠️ Usage
-
Set the client ID in the sketch
#define IMGUR_CLIENT_ID "your-imgur-client-id" -
Create an ImgurUploader instance
ImgurUploader imgurUploader( IMGUR_CLIENT_ID ); -
Connect to the WiFi
WiFi.connect(); -
Send the data
int ret = imgurUploader.uploadFile( SD, "/pic.jpg" ); // or int ret = imgurUploader.uploadBytes( byteArray, arrayLength, "pic.jpg", "image/jpeg" ); // or int ret = imgurUploader.uploadStream( 12345678, &writeStreamCallback, "pic.jpg", "image/jpeg" ); -
Get the resulting imgur.com URL
if( ret > 0 ) { Serial.println( imgurUploader.getURL() ); } else { Serial.println( "Upload failed" ); }
Callbacks
-
Upload progress:
setProgressCallback( &yourProgressFunction )wherevoid yourProgressFunction( byte progress )prints a value between 0 and 100 -
Stream Write:
imgurUploader.uploadStream( streamSize, &writeStreamCallback )wherewriteStreamCallback( Stream* client )writes the image data by chunks (total size must bestreamSizebytes exactly!)