How to upload a sketch on the web server to arduino mega

Hello everyone.
I am working on a project which I use both NodeMCU and Arduino Mega connected via serial. I want to upload the new binary or hex files from an external web server to the MCUs. For the NodeMCU part I am using ESP8266httpUpdate (Arduino/libraries/ESP8266httpUpdate at master · esp8266/Arduino · GitHub) but I have no idea for the Arduino Mega part.

there is no solution for Mega for download a new hex/binary. I made OTA for Mega, but only for upload. You can use the binary storing and applying class InternalStorageAVR from my ArduinoOTA library, but the download is on you.

it requires modified Optiboot to bootload from upper half of the flash