mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
added comments
This commit is contained in:
@@ -34,9 +34,10 @@ export default () => {
|
|||||||
server.middlewares.use(async (req, res, next) => {
|
server.middlewares.use(async (req, res, next) => {
|
||||||
// catch any file uploads
|
// catch any file uploads
|
||||||
if (req.url.startsWith('/rest/uploadFile')) {
|
if (req.url.startsWith('/rest/uploadFile')) {
|
||||||
|
// show progress
|
||||||
let progress = 0;
|
let progress = 0;
|
||||||
const file_size = req.headers['content-length'];
|
const file_size = req.headers['content-length'];
|
||||||
|
console.log('File size: ' + file_size);
|
||||||
req.on('data', async (chunk) => {
|
req.on('data', async (chunk) => {
|
||||||
progress += chunk.length;
|
progress += chunk.length;
|
||||||
const percentage = (progress / file_size) * 100;
|
const percentage = (progress / file_size) * 100;
|
||||||
@@ -50,7 +51,7 @@ export default () => {
|
|||||||
try {
|
try {
|
||||||
[fields, files] = await form.parse(req);
|
[fields, files] = await form.parse(req);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error('Not json form content');
|
||||||
res.writeHead(err.httpCode || 400, {
|
res.writeHead(err.httpCode || 400, {
|
||||||
'Content-Type': 'text/plain'
|
'Content-Type': 'text/plain'
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user