Revision 56253
Added by Konstantinos Triantafyllou almost 5 years ago
modules/uoa-services-portal/trunk/services/upload/uploadService.js | ||
---|---|---|
9 | 9 |
var http = null; |
10 | 10 |
|
11 | 11 |
if(properties.get('ssl')) { |
12 |
http = require("https");
|
|
12 |
http = require("https"); |
|
13 | 13 |
} else { |
14 | 14 |
http = require("http"); |
15 | 15 |
} |
... | ... | |
20 | 20 |
var originServer = properties.get('originServer'); |
21 | 21 |
var allowPostRequests = properties.get('post.allowed').split(','); |
22 | 22 |
var localPath = properties.get('localPath'); |
23 |
var maxsize = properties.get('photo.size')*1024; |
|
23 | 24 |
|
24 | 25 |
var storage = multer.diskStorage({ |
25 | 26 |
destination: function (req, file, cb) { |
... | ... | |
73 | 74 |
console.error("No proper file type"); |
74 | 75 |
res.status(500).send(getResponse(500, "No proper file type")); |
75 | 76 |
} else { |
76 |
//send file |
|
77 | 77 |
res.download(filepath); |
78 | 78 |
} |
79 | 79 |
deleteFile(filepath); |
... | ... | |
93 | 93 |
res.status(500).send(getResponse(500, "No image file type")); |
94 | 94 |
deleteFile(filepath); |
95 | 95 |
} |
96 |
else if (file.size > maxsize) { |
|
97 |
res.status(500).send(getResponse(500, "Exceeds file size limit")); |
|
98 |
deleteFile(filepath); |
|
99 |
} |
|
96 | 100 |
else { |
97 | 101 |
http.get(auth+token, function (resp) { |
98 | 102 |
var responseString = ""; |
... | ... | |
163 | 167 |
} |
164 | 168 |
}); |
165 | 169 |
|
166 |
const server = app.listen(8000, function () {
|
|
170 |
const server = app.listen(8001, function () {
|
|
167 | 171 |
console.log("Listening on port %s...", server.address().port); |
168 | 172 |
}); |
169 | 173 |
|
modules/uoa-services-portal/trunk/services/upload/properties.file | ||
---|---|---|
2 | 2 |
originServer = .di.uoa.gr |
3 | 3 |
post.allowed = /upload,/upload/ |
4 | 4 |
ssl = false |
5 |
localPath = false |
|
5 |
localPath = true |
|
6 |
# photo size in KB |
|
7 |
photo.size = 200 |
Also available in: Unified diff
[Trunk|Services]: Upload Service: add file size limit 200KB.