mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-02-02 23:57:44 +05:00
Merge branch 'master' into async
This commit is contained in:
@@ -172,8 +172,19 @@ protected:
|
||||
sensorSettingsToJson(sensorId, Sensors::settings[sensorId], sensorsettingsDoc);
|
||||
}
|
||||
|
||||
char filename[64];
|
||||
getFilename(filename, sizeof(filename), "backup");
|
||||
|
||||
char contentDispositionValue[128];
|
||||
snprintf_P(
|
||||
contentDispositionValue,
|
||||
sizeof(contentDispositionValue),
|
||||
PSTR("attachment; filename=\"%s\""),
|
||||
filename
|
||||
);
|
||||
|
||||
// send response
|
||||
response->addHeader("Content-Disposition", "attachment; filename=\"backup.json\"");
|
||||
response->addHeader("Content-Disposition", contentDispositionValue);
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
}).addMiddleware(&authMiddleware);
|
||||
@@ -624,8 +635,19 @@ protected:
|
||||
docCrash[FPSTR(S_EPC)] = epcStr;
|
||||
}
|
||||
}
|
||||
char filename[64];
|
||||
getFilename(filename, sizeof(filename), "debug");
|
||||
|
||||
char contentDispositionValue[128];
|
||||
snprintf_P(
|
||||
contentDispositionValue,
|
||||
sizeof(contentDispositionValue),
|
||||
PSTR("attachment; filename=\"%s\""),
|
||||
filename
|
||||
);
|
||||
|
||||
// send response
|
||||
response->addHeader("Content-Disposition", "attachment; filename=\"debug.json\"");
|
||||
response->addHeader("Content-Disposition", contentDispositionValue);
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
}).addMiddleware(&authMiddleware);
|
||||
@@ -783,4 +805,12 @@ protected:
|
||||
this->dnsServer->stop();
|
||||
this->dnsServerEnabled = false;
|
||||
}
|
||||
|
||||
static void getFilename(char* filename, size_t maxSizeFilename, const char* type) {
|
||||
const time_t now = time(nullptr);
|
||||
const tm* localNow = localtime(&now);
|
||||
char localNowValue[20];
|
||||
strftime(localNowValue, sizeof(localNowValue), PSTR("%Y-%m-%d-%H-%M-%S"), localNow);
|
||||
snprintf_P(filename, maxSizeFilename, PSTR("%s_%s_%s.json"), networkSettings.hostname, localNowValue, type);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user