Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SensorDataCollectorAppServer_IOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Miklósi Máté
SensorDataCollectorAppServer_IOS
Commits
f3bb78e3
Commit
f3bb78e3
authored
1 year ago
by
miklosimate
Browse files
Options
Downloads
Patches
Plain Diff
File transfer finally workint, cleenup needed
parent
e7f16a72
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
index.js
+11
-4
11 additions, 4 deletions
index.js
package-lock.json
+86
-16
86 additions, 16 deletions
package-lock.json
package.json
+1
-0
1 addition, 0 deletions
package.json
with
98 additions
and
20 deletions
index.js
+
11
−
4
View file @
f3bb78e3
...
@@ -5,9 +5,14 @@ const ip = require('ip');
...
@@ -5,9 +5,14 @@ const ip = require('ip');
const
app
=
express
();
const
app
=
express
();
const
server
=
http
.
createServer
(
app
);
const
server
=
http
.
createServer
(
app
);
const
fs
=
require
(
'
fs
'
)
const
fs
=
require
(
'
fs
'
)
const
bodyParser
=
require
(
'
body-parser
'
);
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'
public
'
)));
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'
public
'
)));
app
.
use
(
express
.
json
());
// Use express.json() to parse JSON bodies
app
.
use
(
express
.
json
());
// Use express.json() to parse JSON bodies
app
.
use
(
bodyParser
.
json
({
limit
:
'
5mb
'
}));
// Set maximum payload size to 5 MB
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
,
limit
:
'
5mb
'
}));
// Use body-parser to parse plain text request bodies
// Use body-parser to parse plain text request bodies
const
connectedDevices
=
{};
const
connectedDevices
=
{};
...
@@ -83,9 +88,11 @@ app.post('/am-i-ok/:deviceID', (req, res) => {
...
@@ -83,9 +88,11 @@ app.post('/am-i-ok/:deviceID', (req, res) => {
console
.
log
(
'
Sent JSON:
'
,
responseToSend
);
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
deviceID
=
req
.
params
.
deviceID
;
const
f_n
=
req
.
params
.
f_n
;
console
.
log
(
`Json incoming form:
${
deviceID
}
`
)
console
.
log
(
`Json incoming form:
${
deviceID
}
`
)
console
.
log
(
`Json incoming form:
${
f_n
}
`
)
let
responseToSend
let
responseToSend
const
measurementsFolderPath
=
path
.
join
(
__dirname
,
'
measurements
'
,
deviceID
);
const
measurementsFolderPath
=
path
.
join
(
__dirname
,
'
measurements
'
,
deviceID
);
...
@@ -98,13 +105,13 @@ app.post('/json/:deviceID', (req, res) => {
...
@@ -98,13 +105,13 @@ app.post('/json/:deviceID', (req, res) => {
// Get filename from request body
// Get filename from request body
console
.
log
(
"
The body of the request is:
"
)
console
.
log
(
"
The body of the request is:
"
)
console
.
log
(
req
.
body
)
console
.
log
(
req
.
body
)
console
.
log
(
"
The paramter
e
s are:
"
)
console
.
log
(
"
The param
e
ters are:
"
)
console
.
log
(
req
.
params
)
console
.
log
(
req
.
params
)
const
{
filename
,
...
jsonData
}
=
req
.
body
;
const
{
filename
,
...
jsonData
}
=
req
.
body
;
console
.
log
(
"
The filename shold be:
"
,
filename
)
console
.
log
(
`
The filename sho
u
ld be:
${
filename
}
`
)
// Generate unique filename if not provided
// Generate unique filename if not provided
const
fileName
=
f
ilename
||
deviceID
+
'
.json
'
;
const
fileName
=
f
_n
+
'
.json
'
||
deviceID
+
'
.json
'
;
// Path to save the file
// Path to save the file
const
filePath
=
path
.
join
(
measurementsFolderPath
,
fileName
);
const
filePath
=
path
.
join
(
measurementsFolderPath
,
fileName
);
...
...
This diff is collapsed.
Click to expand it.
package-lock.json
+
86
−
16
View file @
f3bb78e3
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
"version"
:
"1.0.0"
,
"version"
:
"1.0.0"
,
"license"
:
"ISC"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"dependencies"
:
{
"body-parser"
:
"^1.20.2"
,
"express"
:
"^4.18.2"
,
"express"
:
"^4.18.2"
,
"ip"
:
"^1.1.8"
,
"ip"
:
"^1.1.8"
,
"node-arp"
:
"^1.0.6"
,
"node-arp"
:
"^1.0.6"
,
...
@@ -46,12 +47,12 @@
...
@@ -46,12 +47,12 @@
"integrity"
:
"sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
"integrity"
:
"sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
},
},
"node_modules/body-parser"
:
{
"node_modules/body-parser"
:
{
"version"
:
"1.20.
1
"
,
"version"
:
"1.20.
2
"
,
"resolved"
:
"https://registry.npmjs.org/body-parser/-/body-parser-1.20.
1
.tgz"
,
"resolved"
:
"https://registry.npmjs.org/body-parser/-/body-parser-1.20.
2
.tgz"
,
"integrity"
:
"sha512-
jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw
=="
,
"integrity"
:
"sha512-
ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA
=="
,
"dependencies"
:
{
"dependencies"
:
{
"bytes"
:
"3.1.2"
,
"bytes"
:
"3.1.2"
,
"content-type"
:
"~1.0.
4
"
,
"content-type"
:
"~1.0.
5
"
,
"debug"
:
"2.6.9"
,
"debug"
:
"2.6.9"
,
"depd"
:
"2.0.0"
,
"depd"
:
"2.0.0"
,
"destroy"
:
"1.2.0"
,
"destroy"
:
"1.2.0"
,
...
@@ -59,7 +60,7 @@
...
@@ -59,7 +60,7 @@
"iconv-lite"
:
"0.4.24"
,
"iconv-lite"
:
"0.4.24"
,
"on-finished"
:
"2.4.1"
,
"on-finished"
:
"2.4.1"
,
"qs"
:
"6.11.0"
,
"qs"
:
"6.11.0"
,
"raw-body"
:
"2.5.
1
"
,
"raw-body"
:
"2.5.
2
"
,
"type-is"
:
"~1.6.18"
,
"type-is"
:
"~1.6.18"
,
"unpipe"
:
"1.0.0"
"unpipe"
:
"1.0.0"
},
},
...
@@ -226,6 +227,43 @@
...
@@ -226,6 +227,43 @@
"node"
:
">= 0.10.0"
"node"
:
">= 0.10.0"
}
}
},
},
"node_modules/express/node_modules/body-parser"
:
{
"version"
:
"1.20.1"
,
"resolved"
:
"https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz"
,
"integrity"
:
"sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw=="
,
"dependencies"
:
{
"bytes"
:
"3.1.2"
,
"content-type"
:
"~1.0.4"
,
"debug"
:
"2.6.9"
,
"depd"
:
"2.0.0"
,
"destroy"
:
"1.2.0"
,
"http-errors"
:
"2.0.0"
,
"iconv-lite"
:
"0.4.24"
,
"on-finished"
:
"2.4.1"
,
"qs"
:
"6.11.0"
,
"raw-body"
:
"2.5.1"
,
"type-is"
:
"~1.6.18"
,
"unpipe"
:
"1.0.0"
},
"engines"
:
{
"node"
:
">= 0.8"
,
"npm"
:
"1.2.8000 || >= 1.4.16"
}
},
"node_modules/express/node_modules/raw-body"
:
{
"version"
:
"2.5.1"
,
"resolved"
:
"https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz"
,
"integrity"
:
"sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig=="
,
"dependencies"
:
{
"bytes"
:
"3.1.2"
,
"http-errors"
:
"2.0.0"
,
"iconv-lite"
:
"0.4.24"
,
"unpipe"
:
"1.0.0"
},
"engines"
:
{
"node"
:
">= 0.8"
}
},
"node_modules/extend"
:
{
"node_modules/extend"
:
{
"version"
:
"3.0.2"
,
"version"
:
"3.0.2"
,
"resolved"
:
"https://registry.npmjs.org/extend/-/extend-3.0.2.tgz"
,
"resolved"
:
"https://registry.npmjs.org/extend/-/extend-3.0.2.tgz"
,
...
@@ -557,9 +595,9 @@
...
@@ -557,9 +595,9 @@
}
}
},
},
"node_modules/raw-body"
:
{
"node_modules/raw-body"
:
{
"version"
:
"2.5.
1
"
,
"version"
:
"2.5.
2
"
,
"resolved"
:
"https://registry.npmjs.org/raw-body/-/raw-body-2.5.
1
.tgz"
,
"resolved"
:
"https://registry.npmjs.org/raw-body/-/raw-body-2.5.
2
.tgz"
,
"integrity"
:
"sha512-
qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig
=="
,
"integrity"
:
"sha512-
8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA
=="
,
"dependencies"
:
{
"dependencies"
:
{
"bytes"
:
"3.1.2"
,
"bytes"
:
"3.1.2"
,
"http-errors"
:
"2.0.0"
,
"http-errors"
:
"2.0.0"
,
...
@@ -751,12 +789,12 @@
...
@@ -751,12 +789,12 @@
"integrity"
:
"sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
"integrity"
:
"sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
},
},
"body-parser"
:
{
"body-parser"
:
{
"version"
:
"1.20.
1
"
,
"version"
:
"1.20.
2
"
,
"resolved"
:
"https://registry.npmjs.org/body-parser/-/body-parser-1.20.
1
.tgz"
,
"resolved"
:
"https://registry.npmjs.org/body-parser/-/body-parser-1.20.
2
.tgz"
,
"integrity"
:
"sha512-
jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw
=="
,
"integrity"
:
"sha512-
ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA
=="
,
"requires"
:
{
"requires"
:
{
"bytes"
:
"3.1.2"
,
"bytes"
:
"3.1.2"
,
"content-type"
:
"~1.0.
4
"
,
"content-type"
:
"~1.0.
5
"
,
"debug"
:
"2.6.9"
,
"debug"
:
"2.6.9"
,
"depd"
:
"2.0.0"
,
"depd"
:
"2.0.0"
,
"destroy"
:
"1.2.0"
,
"destroy"
:
"1.2.0"
,
...
@@ -764,7 +802,7 @@
...
@@ -764,7 +802,7 @@
"iconv-lite"
:
"0.4.24"
,
"iconv-lite"
:
"0.4.24"
,
"on-finished"
:
"2.4.1"
,
"on-finished"
:
"2.4.1"
,
"qs"
:
"6.11.0"
,
"qs"
:
"6.11.0"
,
"raw-body"
:
"2.5.
1
"
,
"raw-body"
:
"2.5.
2
"
,
"type-is"
:
"~1.6.18"
,
"type-is"
:
"~1.6.18"
,
"unpipe"
:
"1.0.0"
"unpipe"
:
"1.0.0"
}
}
...
@@ -891,6 +929,38 @@
...
@@ -891,6 +929,38 @@
"type-is"
:
"~1.6.18"
,
"type-is"
:
"~1.6.18"
,
"utils-merge"
:
"1.0.1"
,
"utils-merge"
:
"1.0.1"
,
"vary"
:
"~1.1.2"
"vary"
:
"~1.1.2"
},
"dependencies"
:
{
"body-parser"
:
{
"version"
:
"1.20.1"
,
"resolved"
:
"https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz"
,
"integrity"
:
"sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw=="
,
"requires"
:
{
"bytes"
:
"3.1.2"
,
"content-type"
:
"~1.0.4"
,
"debug"
:
"2.6.9"
,
"depd"
:
"2.0.0"
,
"destroy"
:
"1.2.0"
,
"http-errors"
:
"2.0.0"
,
"iconv-lite"
:
"0.4.24"
,
"on-finished"
:
"2.4.1"
,
"qs"
:
"6.11.0"
,
"raw-body"
:
"2.5.1"
,
"type-is"
:
"~1.6.18"
,
"unpipe"
:
"1.0.0"
}
},
"raw-body"
:
{
"version"
:
"2.5.1"
,
"resolved"
:
"https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz"
,
"integrity"
:
"sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig=="
,
"requires"
:
{
"bytes"
:
"3.1.2"
,
"http-errors"
:
"2.0.0"
,
"iconv-lite"
:
"0.4.24"
,
"unpipe"
:
"1.0.0"
}
}
}
}
},
},
"extend"
:
{
"extend"
:
{
...
@@ -1133,9 +1203,9 @@
...
@@ -1133,9 +1203,9 @@
"integrity"
:
"sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
"integrity"
:
"sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
},
},
"raw-body"
:
{
"raw-body"
:
{
"version"
:
"2.5.
1
"
,
"version"
:
"2.5.
2
"
,
"resolved"
:
"https://registry.npmjs.org/raw-body/-/raw-body-2.5.
1
.tgz"
,
"resolved"
:
"https://registry.npmjs.org/raw-body/-/raw-body-2.5.
2
.tgz"
,
"integrity"
:
"sha512-
qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig
=="
,
"integrity"
:
"sha512-
8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA
=="
,
"requires"
:
{
"requires"
:
{
"bytes"
:
"3.1.2"
,
"bytes"
:
"3.1.2"
,
"http-errors"
:
"2.0.0"
,
"http-errors"
:
"2.0.0"
,
...
...
This diff is collapsed.
Click to expand it.
package.json
+
1
−
0
View file @
f3bb78e3
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
"author"
:
""
,
"author"
:
""
,
"license"
:
"
ISC
"
,
"license"
:
"
ISC
"
,
"dependencies"
:
{
"dependencies"
:
{
"
body-parser
"
:
"
^1.20.2
"
,
"
express
"
:
"
^4.18.2
"
,
"
express
"
:
"
^4.18.2
"
,
"
ip
"
:
"
^1.1.8
"
,
"
ip
"
:
"
^1.1.8
"
,
"
node-arp
"
:
"
^1.0.6
"
,
"
node-arp
"
:
"
^1.0.6
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment