From 1dd675af8b58fd7820a1d47742c8bf963c0a5470 Mon Sep 17 00:00:00 2001
From: miklosimate <megykereku@gmail.com>
Date: Mon, 11 Mar 2024 00:22:09 +0100
Subject: [PATCH] File transfer finally workint, cleenup needed

---
 index.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/index.js b/index.js
index 601f5e3..88731af 100644
--- a/index.js
+++ b/index.js
@@ -83,9 +83,11 @@ app.post('/am-i-ok/:deviceID', (req, res) => {
     console.log('Sent JSON:', responseToSend);
 });
 
-app.post('/json/:deviceID', (req, res) => {
+app.post('/json/:deviceID/:f_n', (req, res) => {
     const deviceID = req.params.deviceID;
+    const f_n = req.params.f_n;
     console.log(`Json incoming form: ${deviceID}`)
+    console.log(`Json incoming form: ${f_n}`)
     let responseToSend
 
     const measurementsFolderPath = path.join(__dirname, 'measurements', deviceID);
@@ -98,13 +100,13 @@ app.post('/json/:deviceID', (req, res) => {
     // Get filename from request body
     console.log("The body of the request is:")
     console.log(req.body)
-    console.log("The paramteres are:")
+    console.log("The parameters are:")
     console.log(req.params)
     const { filename, ...jsonData } = req.body;
-    console.log("The filename shold be:", filename)
+    console.log(`The filename should be: ${filename}`)
 
     // Generate unique filename if not provided
-    const fileName = filename || deviceID + '.json';
+    const fileName = f_n || deviceID + '.json';
 
     // Path to save the file
     const filePath = path.join(measurementsFolderPath, fileName);
-- 
GitLab