파일 분할 코멘트 추가

This commit is contained in:
2026-02-24 20:19:38 +00:00
parent 0baac2bf90
commit 7e0e65297b
5 changed files with 276 additions and 13 deletions

View File

@@ -353,6 +353,29 @@ void setupWebRoutes() {
server.streamFile(file, "text/csv");
file.close();
});
// --- Set/Update file comment ---
server.on("/api/comment", HTTP_POST, []() {
if (!server.hasArg("plain")) {
server.send(400, "application/json", "{\"error\":\"no body\"}");
return;
}
StaticJsonDocument<512> doc;
DeserializationError err = deserializeJson(doc, server.arg("plain"));
if (err) {
server.send(400, "application/json", "{\"error\":\"invalid json\"}");
return;
}
const char *fname = doc["file"];
const char *comment = doc["comment"] | "";
if (!fname) {
server.send(400, "application/json", "{\"error\":\"missing file\"}");
return;
}
bool ok = sdSetComment(fname, comment);
String resp = "{\"ok\":" + String(ok ? "true" : "false") + "}";
server.send(200, "application/json", resp);
});
}
// ============================================================