How to download csv/txt file from SD card over webserver?

Hi,

I am trying to make a system in which I can be able to download the saved txt or csv files (saved in SD card) via webpage hosted by ESP 32. But I am not able to decide that how actually I can transfer the file as whole. We are using java script and HTML for webpage designing. Can someone help me out with a code snippet or something that I can refer to?

Thanks in advance! :)

It may be easier to transfer data over a TCP connection, search by socket.

Since ESP32 is similar to ESP8266, see if this example helps::

ESP8266 NodeMCU TCP Socket Server Arduino Example

I've never done this, but my understanding it that it should be very easy using http protocol. A webpage hosted by the esp, maybe the root web page, would include link(s) to the files(s) available to be downloaded. When the user clicks such a link, a request for that file name will be sent to the esp. The esp will see the requested file name and detect that a download file has been requested, rather than the root webpage or other webpage. It would then open the SD card file, read each record from it, and print them to the requesting client, in CSV or other text format. The user's browser, knowing that the requested page is a .CSV or .TXT, rather than a .HTML webpage, would treat the response from the esp as a download file and save it to the downloads folder. I think it should be as simple as that.