File Arduino ESP8266从Web服务器下载大文件

File Arduino ESP8266从Web服务器下载大文件,file,download,arduino,webserver,esp8266,File,Download,Arduino,Webserver,Esp8266,我正在尝试读取SD卡上的一个大文件,并将其发送到连接到web服务器的客户端。对于服务器,我使用ESP8266WebServer.h 到目前为止,我唯一的选择是: httpServer.sendHeader("Content-Type", "text/text"); httpServer.sendHeader("Content-Disposition", "attachment; filename=\"download.txt\""); httpServer.sendHeader("Connect

我正在尝试读取SD卡上的一个大文件,并将其发送到连接到web服务器的客户端。对于服务器,我使用ESP8266WebServer.h

到目前为止,我唯一的选择是:

httpServer.sendHeader("Content-Type", "text/text");
httpServer.sendHeader("Content-Disposition", "attachment; filename=\"download.txt\"");
httpServer.sendHeader("Connection", "close");
File download = SD.open("test.txt");
String buffer = download.readString();
httpServer.send(200, "text/text", buffer);
download.close();
这对我不可用,因为该文件无法放入堆栈。是否有一种方法可以连续向客户发送数据?我尝试了httpServer.sendContent(),但发送的数据仅显示为网页内容,发送()在第一次数据发送后关闭连接

编辑:

在示例中找到解决方案

httpServer.streamFile(download, "application/octet-stream");

你查过了吗?@gre_gor谢谢你!我完全忘记了例子