File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 'use strict'
2+ const config = require ( '../../config' )
3+ const logger = require ( '../../logger' )
4+
5+ const lutim = require ( 'lutim' )
6+
7+ exports . uploadImage = function ( imagePath , callback ) {
8+ if ( ! imagePath || typeof imagePath !== 'string' ) {
9+ callback ( new Error ( 'Image path is missing or wrong' ) , null )
10+ return
11+ }
12+
13+ if ( ! callback || typeof callback !== 'function' ) {
14+ logger . error ( 'Callback has to be a function' )
15+ return
16+ }
17+
18+ if ( config . lutim && config . lutim . url ) {
19+ lutim . setAPIUrl ( config . lutim . url )
20+ }
21+
22+ lutim . uploadImage ( imagePath )
23+ . then ( function ( json ) {
24+ if ( config . debug ) {
25+ logger . info ( 'SERVER uploadimage success: ' + JSON . stringify ( json ) )
26+ }
27+ callback ( null , lutim . getAPIUrl ( ) + json . msg . short )
28+ } ) . catch ( function ( err ) {
29+ callback ( new Error ( err ) , null )
30+ } )
31+ }
You can’t perform that action at this time.
0 commit comments