summaryrefslogtreecommitdiff
path: root/lib/web/imageRouter/filesystem.js
diff options
context:
space:
mode:
authorChristoph (Sheogorath) Kern2018-03-21 14:13:32 +0100
committerGitHub2018-03-21 14:13:32 +0100
commit6485f9665976adfc3dc17233c1922efb89e5d43a (patch)
tree9b5356ada5cda0e1a5cf0a1eb7e81398622e139b /lib/web/imageRouter/filesystem.js
parent6e6a98b392f78567e98a9b49ff0dd193f885e242 (diff)
parent1756e76dc31495d03c8792fa672ae6bb94d24ea8 (diff)
Merge pull request #771 from SISheogorath/refactor/imageRouter
Refactoring imageRouter to modularity
Diffstat (limited to '')
-rw-r--r--lib/web/imageRouter/filesystem.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/web/imageRouter/filesystem.js b/lib/web/imageRouter/filesystem.js
new file mode 100644
index 00000000..25ec3846
--- /dev/null
+++ b/lib/web/imageRouter/filesystem.js
@@ -0,0 +1,18 @@
+'use strict'
+const url = require('url')
+
+const config = require('../../config')
+
+exports.uploadImage = function (imagePath, callback) {
+ if (!imagePath || typeof imagePath !== 'string') {
+ callback(new Error('Image path is missing or wrong'), null)
+ return
+ }
+
+ if (!callback || typeof callback !== 'function') {
+ callback(new Error('Callback has to be a function'), null)
+ return
+ }
+
+ callback(null, url.resolve(config.serverurl + '/', imagePath.match(/^public\/(.+$)/)[1]))
+}