Skip to content
Snippets Groups Projects
Commit 1dd675af authored by miklosimate's avatar miklosimate
Browse files

File transfer finally workint, cleenup needed

parent e7f16a72
Branches
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment