some time ago I've written a sketch for an UNO which uses SD and Ethernet at the same time and I tried this also for the MEGA now and imho it works:
It is just a small data logger which
- writes data to the SD Card,
- a NTP client to get the current time (for logging)
- and webserver to download the data from the SD Card:
https://werner.rothschopf.net/microcontroller/202108_arduino_webserver_ntp_sd_en.htm
and by the way, I'm using Juraj's StreamLib ![]()