Skip to content

Commit 291fd5c

Browse files
committed
Fix example
1 parent b29efc4 commit 291fd5c

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

libraries/WebServer/examples/UploadHugeFile/UploadHugeFile.ino

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
#include <WiFi.h>
22
#include <WiFiClient.h>
33
#include <WebServer.h>
4-
#include <SD.h>
4+
#include <SD_MMC.h>
5+
6+
#include <uri/UriRegex.h>
57

68
const char* ssid = "**********";
79
const char* password = "**********";
810

911
WebServer server(80);
1012

1113
File rawFile;
14+
1215
void handleCreate() {
1316
server.send(200, "text/plain", "");
1417
}
18+
1519
void handleCreateProcess() {
1620
String path = server.pathArg(0);
1721
HTTPRaw& raw = server.raw();
1822
if (raw.status == RAW_START) {
19-
if (SD.exists((char *)path.c_str())) {
20-
SD.remove((char *)path.c_str());
23+
if (SD_MMC.exists((char *)path.c_str())) {
24+
SD_MMC.remove((char *)path.c_str());
2125
}
22-
rawFile = SD.open(path.c_str(), FILE_WRITE);
26+
rawFile = SD_MMC.open(path.c_str(), FILE_WRITE);
2327
Serial.print("Upload: START, filename: ");
2428
Serial.println(path);
2529
} else if (raw.status == RAW_WRITE) {
@@ -46,10 +50,10 @@ void printDirectory() {
4650
return returnFail("BAD ARGS");
4751
}
4852
String path = server.arg("dir");
49-
if (path != "/" && !SD.exists((char *)path.c_str())) {
53+
if (path != "/" && !SD_MMC.exists((char *)path.c_str())) {
5054
return returnFail("BAD PATH");
5155
}
52-
File dir = SD.open((char *)path.c_str());
56+
File dir = SD_MMC.open((char *)path.c_str());
5357
path = String();
5458
if (!dir.isDirectory()) {
5559
dir.close();
@@ -98,14 +102,13 @@ void handleNotFound() {
98102
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
99103
}
100104
server.send(404, "text/plain", message);
101-
digitalWrite(led, 0);
102105
}
103106

104107
void setup(void) {
105108
Serial.begin(115200);
106109

107-
while (!SD.begin()) delay();
108-
Serial.println("SD Card initialized.");
110+
while (!SD_MMC.begin()) delay(10);
111+
Serial.println("SD_MMC Card initialized.");
109112

110113
WiFi.mode(WIFI_STA);
111114
WiFi.begin(ssid, password);
@@ -122,7 +125,7 @@ void setup(void) {
122125
server.on(UriRegex("/upload/(.*)"), HTTP_PUT, handleCreate, handleCreateProcess);
123126
server.onNotFound(handleNotFound);
124127
server.begin();
125-
server.println("HTTP server started");
128+
Serial.println("HTTP server started");
126129

127130
}
128131

0 commit comments

Comments
 (0)