diff options
author | Dylan Dervaux | 2019-02-01 12:33:27 +0100 |
---|---|---|
committer | Sheogorath | 2019-04-10 01:37:12 +0200 |
commit | 208070d2e776c437154e6ead552364b3956adf1c (patch) | |
tree | 4e24aed2c2be442ede4bf3cbe9e8dc0e6be178df /lib/web/imageRouter | |
parent | 36c083277e6c74bb6eac495971522e6932cfc207 (diff) |
Add lutim support
Signed-off-by: Dylan Dervaux <dylanderv05@gmail.com>
Diffstat (limited to '')
-rw-r--r-- | lib/web/imageRouter/lutim.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/web/imageRouter/lutim.js b/lib/web/imageRouter/lutim.js new file mode 100644 index 00000000..78b856c9 --- /dev/null +++ b/lib/web/imageRouter/lutim.js @@ -0,0 +1,31 @@ +'use strict' +const config = require('../../config') +const logger = require('../../logger') + +const lutim = require('lutim') + +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') { + logger.error('Callback has to be a function') + return + } + + if (config.lutim && config.lutim.url) { + lutim.setAPIUrl(config.lutim.url) + } + + lutim.uploadImage(imagePath) + .then(function (json) { + if (config.debug) { + logger.info('SERVER uploadimage success: ' + JSON.stringify(json)) + } + callback(null, lutim.getAPIUrl() + json.msg.short) + }).catch(function (err) { + callback(new Error(err), null) + }) +} |