aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/controllers/api/v1/clients.js7
-rw-r--r--server/controllers/api/v1/videos.js5
-rw-r--r--server/helpers/logger.js10
-rw-r--r--server/helpers/peertube-crypto.js29
-rw-r--r--server/helpers/requests.js11
-rw-r--r--server/initializers/constants.js27
-rw-r--r--server/initializers/database.js8
-rw-r--r--server/lib/friends.js8
-rw-r--r--server/lib/webtorrent.js9
-rw-r--r--server/models/video.js23
10 files changed, 72 insertions, 65 deletions
diff --git a/server/controllers/api/v1/clients.js b/server/controllers/api/v1/clients.js
index 0d222634b..5b460db2e 100644
--- a/server/controllers/api/v1/clients.js
+++ b/server/controllers/api/v1/clients.js
@@ -1,9 +1,10 @@
1'use strict' 1'use strict'
2 2
3const config = require('config')
4const express = require('express') 3const express = require('express')
5const mongoose = require('mongoose') 4const mongoose = require('mongoose')
6 5
6const constants = require('../../../initializers/constants')
7
7const Client = mongoose.model('OAuthClient') 8const Client = mongoose.model('OAuthClient')
8 9
9const router = express.Router() 10const router = express.Router()
@@ -12,8 +13,8 @@ router.get('/local', getLocalClient)
12 13
13// Get the client credentials for the PeerTube front end 14// Get the client credentials for the PeerTube front end
14function getLocalClient (req, res, next) { 15function getLocalClient (req, res, next) {
15 const serverHost = config.get('webserver.host') 16 const serverHost = constants.CONFIG.WEBSERVER.HOST
16 const serverPort = config.get('webserver.port') 17 const serverPort = constants.CONFIG.WEBSERVER.PORT
17 let headerHostShouldBe = serverHost 18 let headerHostShouldBe = serverHost
18 if (serverPort !== 80 && serverPort !== 443) { 19 if (serverPort !== 80 && serverPort !== 443) {
19 headerHostShouldBe += ':' + serverPort 20 headerHostShouldBe += ':' + serverPort
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js
index 0a441f146..70d22f139 100644
--- a/server/controllers/api/v1/videos.js
+++ b/server/controllers/api/v1/videos.js
@@ -1,11 +1,11 @@
1'use strict' 1'use strict'
2 2
3const config = require('config')
4const express = require('express') 3const express = require('express')
5const mongoose = require('mongoose') 4const mongoose = require('mongoose')
6const multer = require('multer') 5const multer = require('multer')
7const waterfall = require('async/waterfall') 6const waterfall = require('async/waterfall')
8 7
8const constants = require('../../../initializers/constants')
9const logger = require('../../../helpers/logger') 9const logger = require('../../../helpers/logger')
10const friends = require('../../../lib/friends') 10const friends = require('../../../lib/friends')
11const middlewares = require('../../../middlewares') 11const middlewares = require('../../../middlewares')
@@ -20,13 +20,12 @@ const sort = middlewares.sort
20const utils = require('../../../helpers/utils') 20const utils = require('../../../helpers/utils')
21 21
22const router = express.Router() 22const router = express.Router()
23const uploads = config.get('storage.uploads')
24const Video = mongoose.model('Video') 23const Video = mongoose.model('Video')
25 24
26// multer configuration 25// multer configuration
27const storage = multer.diskStorage({ 26const storage = multer.diskStorage({
28 destination: function (req, file, cb) { 27 destination: function (req, file, cb) {
29 cb(null, uploads) 28 cb(null, constants.CONFIG.STORAGE.UPLOAD_DIR)
30 }, 29 },
31 30
32 filename: function (req, file, cb) { 31 filename: function (req, file, cb) {
diff --git a/server/helpers/logger.js b/server/helpers/logger.js
index 8ae90a4b2..590ceaeb6 100644
--- a/server/helpers/logger.js
+++ b/server/helpers/logger.js
@@ -1,23 +1,23 @@
1// Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/ 1// Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
2'use strict' 2'use strict'
3 3
4const config = require('config')
5const mkdirp = require('mkdirp') 4const mkdirp = require('mkdirp')
6const path = require('path') 5const path = require('path')
7const winston = require('winston') 6const winston = require('winston')
8winston.emitErrs = true 7winston.emitErrs = true
9 8
10const logDir = path.join(__dirname, '..', '..', config.get('storage.logs')) 9const constants = require('../initializers/constants')
11const label = config.get('webserver.host') + ':' + config.get('webserver.port') 10
11const label = constants.CONFIG.WEBSERVER.HOST + ':' + constants.CONFIG.WEBSERVER.PORT
12 12
13// Create the directory if it does not exist 13// Create the directory if it does not exist
14mkdirp.sync(logDir) 14mkdirp.sync(constants.CONFIG.STORAGE.LOG_DIR)
15 15
16const logger = new winston.Logger({ 16const logger = new winston.Logger({
17 transports: [ 17 transports: [
18 new winston.transports.File({ 18 new winston.transports.File({
19 level: 'debug', 19 level: 'debug',
20 filename: path.join(logDir, 'all-logs.log'), 20 filename: path.join(constants.CONFIG.STORAGE.LOG_DIR, 'all-logs.log'),
21 handleExceptions: true, 21 handleExceptions: true,
22 json: true, 22 json: true,
23 maxsize: 5242880, 23 maxsize: 5242880,
diff --git a/server/helpers/peertube-crypto.js b/server/helpers/peertube-crypto.js
index 46dff8d03..ef130ea5c 100644
--- a/server/helpers/peertube-crypto.js
+++ b/server/helpers/peertube-crypto.js
@@ -1,15 +1,13 @@
1'use strict' 1'use strict'
2 2
3const config = require('config')
4const crypto = require('crypto') 3const crypto = require('crypto')
5const fs = require('fs') 4const fs = require('fs')
6const openssl = require('openssl-wrapper') 5const openssl = require('openssl-wrapper')
7const path = require('path')
8const ursa = require('ursa') 6const ursa = require('ursa')
9 7
8const constants = require('../initializers/constants')
10const logger = require('./logger') 9const logger = require('./logger')
11 10
12const certDir = path.join(__dirname, '..', '..', config.get('storage.certs'))
13const algorithm = 'aes-256-ctr' 11const algorithm = 'aes-256-ctr'
14 12
15const peertubeCrypto = { 13const peertubeCrypto = {
@@ -17,7 +15,6 @@ const peertubeCrypto = {
17 createCertsIfNotExist: createCertsIfNotExist, 15 createCertsIfNotExist: createCertsIfNotExist,
18 decrypt: decrypt, 16 decrypt: decrypt,
19 encrypt: encrypt, 17 encrypt: encrypt,
20 getCertDir: getCertDir,
21 sign: sign 18 sign: sign
22} 19}
23 20
@@ -40,7 +37,7 @@ function createCertsIfNotExist (callback) {
40} 37}
41 38
42function decrypt (key, data, callback) { 39function decrypt (key, data, callback) {
43 fs.readFile(getCertDir() + 'peertube.key.pem', function (err, file) { 40 fs.readFile(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.key.pem', function (err, file) {
44 if (err) return callback(err) 41 if (err) return callback(err)
45 42
46 const myPrivateKey = ursa.createPrivateKey(file) 43 const myPrivateKey = ursa.createPrivateKey(file)
@@ -67,12 +64,8 @@ function encrypt (publicKey, data, callback) {
67 }) 64 })
68} 65}
69 66
70function getCertDir () {
71 return certDir
72}
73
74function sign (data) { 67function sign (data) {
75 const myKey = ursa.createPrivateKey(fs.readFileSync(certDir + 'peertube.key.pem')) 68 const myKey = ursa.createPrivateKey(fs.readFileSync(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.key.pem'))
76 const signature = myKey.hashAndSign('sha256', data, 'utf8', 'hex') 69 const signature = myKey.hashAndSign('sha256', data, 'utf8', 'hex')
77 70
78 return signature 71 return signature
@@ -85,7 +78,7 @@ module.exports = peertubeCrypto
85// --------------------------------------------------------------------------- 78// ---------------------------------------------------------------------------
86 79
87function certsExist (callback) { 80function certsExist (callback) {
88 fs.exists(certDir + 'peertube.key.pem', function (exists) { 81 fs.exists(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.key.pem', function (exists) {
89 return callback(exists) 82 return callback(exists)
90 }) 83 })
91} 84}
@@ -99,15 +92,25 @@ function createCerts (callback) {
99 } 92 }
100 93
101 logger.info('Generating a RSA key...') 94 logger.info('Generating a RSA key...')
102 openssl.exec('genrsa', { 'out': certDir + 'peertube.key.pem', '2048': false }, function (err) { 95
96 let options = {
97 'out': constants.CONFIG.STORAGE.CERT_DIR + 'peertube.key.pem',
98 '2048': false
99 }
100 openssl.exec('genrsa', options, function (err) {
103 if (err) { 101 if (err) {
104 logger.error('Cannot create private key on this pod.') 102 logger.error('Cannot create private key on this pod.')
105 return callback(err) 103 return callback(err)
106 } 104 }
107 logger.info('RSA key generated.') 105 logger.info('RSA key generated.')
108 106
107 options = {
108 'in': constants.CONFIG.STORAGE.CERT_DIR + 'peertube.key.pem',
109 'pubout': true,
110 'out': constants.CONFIG.STORAGE.CERT_DIR + 'peertube.pub'
111 }
109 logger.info('Manage public key...') 112 logger.info('Manage public key...')
110 openssl.exec('rsa', { 'in': certDir + 'peertube.key.pem', 'pubout': true, 'out': certDir + 'peertube.pub' }, function (err) { 113 openssl.exec('rsa', options, function (err) {
111 if (err) { 114 if (err) {
112 logger.error('Cannot create public key on this pod.') 115 logger.error('Cannot create public key on this pod.')
113 return callback(err) 116 return callback(err)
diff --git a/server/helpers/requests.js b/server/helpers/requests.js
index 547230adc..f76ff3473 100644
--- a/server/helpers/requests.js
+++ b/server/helpers/requests.js
@@ -1,16 +1,11 @@
1'use strict' 1'use strict'
2 2
3const config = require('config')
4const replay = require('request-replay') 3const replay = require('request-replay')
5const request = require('request') 4const request = require('request')
6 5
7const constants = require('../initializers/constants') 6const constants = require('../initializers/constants')
8const peertubeCrypto = require('./peertube-crypto') 7const peertubeCrypto = require('./peertube-crypto')
9 8
10const http = config.get('webserver.https') ? 'https' : 'http'
11const host = config.get('webserver.host')
12const port = config.get('webserver.port')
13
14const requests = { 9const requests = {
15 makeRetryRequest: makeRetryRequest, 10 makeRetryRequest: makeRetryRequest,
16 makeSecureRequest: makeSecureRequest 11 makeSecureRequest: makeSecureRequest
@@ -29,8 +24,6 @@ function makeRetryRequest (params, callback) {
29} 24}
30 25
31function makeSecureRequest (params, callback) { 26function makeSecureRequest (params, callback) {
32 const myUrl = http + '://' + host + ':' + port
33
34 const requestParams = { 27 const requestParams = {
35 url: params.toPod.url + params.path 28 url: params.toPod.url + params.path
36 } 29 }
@@ -42,8 +35,8 @@ function makeSecureRequest (params, callback) {
42 // Add signature if it is specified in the params 35 // Add signature if it is specified in the params
43 if (params.sign === true) { 36 if (params.sign === true) {
44 requestParams.json.signature = { 37 requestParams.json.signature = {
45 url: myUrl, 38 url: constants.CONFIG.WEBSERVER.URL,
46 signature: peertubeCrypto.sign(myUrl) 39 signature: peertubeCrypto.sign(constants.CONFIG.WEBSERVER.URL)
47 } 40 }
48 } 41 }
49 42
diff --git a/server/initializers/constants.js b/server/initializers/constants.js
index cd2e0cfb9..ce9f8ad6c 100644
--- a/server/initializers/constants.js
+++ b/server/initializers/constants.js
@@ -1,8 +1,34 @@
1'use strict' 1'use strict'
2 2
3const config = require('config')
4const path = require('path')
5
3// API version of our pod 6// API version of our pod
4const API_VERSION = 'v1' 7const API_VERSION = 'v1'
5 8
9const CONFIG = {
10 DATABASE: {
11 DBNAME: 'peertube' + config.get('database.suffix'),
12 HOST: config.get('database.host'),
13 PORT: config.get('database.port')
14 },
15 ELECTRON: {
16 DEBUG: config.get('electron.debug')
17 },
18 STORAGE: {
19 CERT_DIR: path.join(__dirname, '..', '..', config.get('storage.certs')),
20 LOG_DIR: path.join(__dirname, '..', '..', config.get('storage.logs')),
21 UPLOAD_DIR: path.join(__dirname, '..', '..', config.get('storage.uploads')),
22 THUMBNAILS_DIR: path.join(__dirname, '..', '..', config.get('storage.thumbnails'))
23 },
24 WEBSERVER: {
25 SCHEME: config.get('webserver.https') === true ? 'https' : 'http',
26 HOST: config.get('webserver.host'),
27 PORT: config.get('webserver.port')
28 }
29}
30CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOST + ':' + CONFIG.WEBSERVER.PORT
31
6const CONSTRAINTS_FIELDS = { 32const CONSTRAINTS_FIELDS = {
7 USERS: { 33 USERS: {
8 USERNAME: { min: 3, max: 20 }, // Length 34 USERNAME: { min: 3, max: 20 }, // Length
@@ -89,6 +115,7 @@ if (isTestInstance() === true) {
89 115
90module.exports = { 116module.exports = {
91 API_VERSION: API_VERSION, 117 API_VERSION: API_VERSION,
118 CONFIG: CONFIG,
92 CONSTRAINTS_FIELDS: CONSTRAINTS_FIELDS, 119 CONSTRAINTS_FIELDS: CONSTRAINTS_FIELDS,
93 FRIEND_SCORE: FRIEND_SCORE, 120 FRIEND_SCORE: FRIEND_SCORE,
94 INTERVAL: INTERVAL, 121 INTERVAL: INTERVAL,
diff --git a/server/initializers/database.js b/server/initializers/database.js
index 8626895ee..20dcc056e 100644
--- a/server/initializers/database.js
+++ b/server/initializers/database.js
@@ -1,8 +1,8 @@
1'use strict' 1'use strict'
2 2
3const config = require('config')
4const mongoose = require('mongoose') 3const mongoose = require('mongoose')
5 4
5const constants = require('../initializers/constants')
6const logger = require('../helpers/logger') 6const logger = require('../helpers/logger')
7 7
8// Bootstrap models 8// Bootstrap models
@@ -14,17 +14,13 @@ require('../models/video')
14// Request model needs Video model 14// Request model needs Video model
15require('../models/request') 15require('../models/request')
16 16
17const dbname = 'peertube' + config.get('database.suffix')
18const host = config.get('database.host')
19const port = config.get('database.port')
20
21const database = { 17const database = {
22 connect: connect 18 connect: connect
23} 19}
24 20
25function connect () { 21function connect () {
26 mongoose.Promise = global.Promise 22 mongoose.Promise = global.Promise
27 mongoose.connect('mongodb://' + host + ':' + port + '/' + dbname) 23 mongoose.connect('mongodb://' + constants.CONFIG.DATABASE.HOST + ':' + constants.CONFIG.DATABASE.PORT + '/' + constants.CONFIG.DATABASE.DBNAME)
28 mongoose.connection.on('error', function () { 24 mongoose.connection.on('error', function () {
29 throw new Error('Mongodb connection error.') 25 throw new Error('Mongodb connection error.')
30 }) 26 })
diff --git a/server/lib/friends.js b/server/lib/friends.js
index 6e1516b94..6a2c37fd7 100644
--- a/server/lib/friends.js
+++ b/server/lib/friends.js
@@ -11,12 +11,8 @@ const waterfall = require('async/waterfall')
11 11
12const constants = require('../initializers/constants') 12const constants = require('../initializers/constants')
13const logger = require('../helpers/logger') 13const logger = require('../helpers/logger')
14const peertubeCrypto = require('../helpers/peertube-crypto')
15const requests = require('../helpers/requests') 14const requests = require('../helpers/requests')
16 15
17const http = config.get('webserver.https') ? 'https' : 'http'
18const host = config.get('webserver.host')
19const port = config.get('webserver.port')
20const Pod = mongoose.model('Pod') 16const Pod = mongoose.model('Pod')
21const Request = mongoose.model('Request') 17const Request = mongoose.model('Request')
22const Video = mongoose.model('Video') 18const Video = mongoose.model('Video')
@@ -45,7 +41,7 @@ function hasFriends (callback) {
45} 41}
46 42
47function getMyCertificate (callback) { 43function getMyCertificate (callback) {
48 fs.readFile(peertubeCrypto.getCertDir() + 'peertube.pub', 'utf8', callback) 44 fs.readFile(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.pub', 'utf8', callback)
49} 45}
50 46
51function makeFriends (callback) { 47function makeFriends (callback) {
@@ -220,7 +216,7 @@ function makeRequestsToWinningPods (cert, podsList, callback) {
220 url: pod.url + '/api/' + constants.API_VERSION + '/pods/', 216 url: pod.url + '/api/' + constants.API_VERSION + '/pods/',
221 method: 'POST', 217 method: 'POST',
222 json: { 218 json: {
223 url: http + '://' + host + ':' + port, 219 url: constants.CONFIG.WEBSERVER.URL,
224 publicKey: cert 220 publicKey: cert
225 } 221 }
226 } 222 }
diff --git a/server/lib/webtorrent.js b/server/lib/webtorrent.js
index bcd30139e..2090b792b 100644
--- a/server/lib/webtorrent.js
+++ b/server/lib/webtorrent.js
@@ -1,15 +1,14 @@
1'use strict' 1'use strict'
2 2
3const config = require('config')
4const ipc = require('node-ipc') 3const ipc = require('node-ipc')
5const pathUtils = require('path') 4const pathUtils = require('path')
6const spawn = require('electron-spawn') 5const spawn = require('electron-spawn')
7 6
7const constants = require('../initializers/constants')
8const logger = require('../helpers/logger') 8const logger = require('../helpers/logger')
9 9
10const electronDebug = config.get('electron.debug') 10let host = constants.CONFIG.WEBSERVER.HOST
11let host = config.get('webserver.host') 11let port = constants.CONFIG.WEBSERVER.PORT
12let port = config.get('webserver.port')
13let nodeKey = 'webtorrentnode' + port 12let nodeKey = 'webtorrentnode' + port
14let processKey = 'webtorrentprocess' + port 13let processKey = 'webtorrentprocess' + port
15ipc.config.silent = true 14ipc.config.silent = true
@@ -59,7 +58,7 @@ function create (options, callback) {
59 58
60 const webtorrentProcess = spawn(pathUtils.join(__dirname, 'webtorrent-process.js'), host, port, { detached: true }) 59 const webtorrentProcess = spawn(pathUtils.join(__dirname, 'webtorrent-process.js'), host, port, { detached: true })
61 60
62 if (electronDebug === true) { 61 if (constants.CONFIG.ELECTRON.DEBUG === true) {
63 webtorrentProcess.stderr.on('data', function (data) { 62 webtorrentProcess.stderr.on('data', function (data) {
64 logger.debug('Webtorrent process stderr: ', data.toString()) 63 logger.debug('Webtorrent process stderr: ', data.toString())
65 }) 64 })
diff --git a/server/models/video.js b/server/models/video.js
index 63afc2efe..0f60b6cd4 100644
--- a/server/models/video.js
+++ b/server/models/video.js
@@ -1,6 +1,5 @@
1'use strict' 1'use strict'
2 2
3const config = require('config')
4const eachLimit = require('async/eachLimit') 3const eachLimit = require('async/eachLimit')
5const ffmpeg = require('fluent-ffmpeg') 4const ffmpeg = require('fluent-ffmpeg')
6const fs = require('fs') 5const fs = require('fs')
@@ -15,12 +14,6 @@ const modelUtils = require('./utils')
15const utils = require('../helpers/utils') 14const utils = require('../helpers/utils')
16const webtorrent = require('../lib/webtorrent') 15const webtorrent = require('../lib/webtorrent')
17 16
18const http = config.get('webserver.https') === true ? 'https' : 'http'
19const host = config.get('webserver.host')
20const port = config.get('webserver.port')
21const uploadsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.uploads'))
22const thumbnailsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.thumbnails'))
23
24// --------------------------------------------------------------------------- 17// ---------------------------------------------------------------------------
25 18
26// TODO: add indexes on searchable columns 19// TODO: add indexes on searchable columns
@@ -101,8 +94,8 @@ VideoSchema.pre('save', function (next) {
101 const tasks = [] 94 const tasks = []
102 95
103 if (video.isOwned()) { 96 if (video.isOwned()) {
104 const videoPath = pathUtils.join(uploadsDir, video.filename) 97 const videoPath = pathUtils.join(constants.CONFIG.STORAGE.UPLOAD_DIR, video.filename)
105 this.podUrl = http + '://' + host + ':' + port 98 this.podUrl = constants.CONFIG.WEBSERVER.URL
106 99
107 tasks.push( 100 tasks.push(
108 function (callback) { 101 function (callback) {
@@ -162,7 +155,7 @@ function toRemoteJSON (callback) {
162 const self = this 155 const self = this
163 156
164 // Convert thumbnail to base64 157 // Convert thumbnail to base64
165 fs.readFile(pathUtils.join(thumbnailsDir, this.thumbnail), function (err, thumbnailData) { 158 fs.readFile(pathUtils.join(constants.CONFIG.STORAGE.THUMBNAILS_DIR, this.thumbnail), function (err, thumbnailData) {
166 if (err) { 159 if (err) {
167 logger.error('Cannot read the thumbnail of the video') 160 logger.error('Cannot read the thumbnail of the video')
168 return callback(err) 161 return callback(err)
@@ -242,7 +235,7 @@ function seedAllExisting (callback) {
242 if (err) return callback(err) 235 if (err) return callback(err)
243 236
244 eachLimit(videos, constants.SEEDS_IN_PARALLEL, function (video, callbackEach) { 237 eachLimit(videos, constants.SEEDS_IN_PARALLEL, function (video, callbackEach) {
245 const videoPath = pathUtils.join(uploadsDir, video.filename) 238 const videoPath = pathUtils.join(constants.CONFIG.STORAGE.UPLOAD_DIR, video.filename)
246 seed(videoPath, callbackEach) 239 seed(videoPath, callbackEach)
247 }, callback) 240 }, callback)
248 }) 241 })
@@ -251,11 +244,11 @@ function seedAllExisting (callback) {
251// --------------------------------------------------------------------------- 244// ---------------------------------------------------------------------------
252 245
253function removeThumbnail (video, callback) { 246function removeThumbnail (video, callback) {
254 fs.unlink(thumbnailsDir + video.thumbnail, callback) 247 fs.unlink(constants.CONFIG.STORAGE.THUMBNAILS_DIR + video.thumbnail, callback)
255} 248}
256 249
257function removeFile (video, callback) { 250function removeFile (video, callback) {
258 fs.unlink(uploadsDir + video.filename, callback) 251 fs.unlink(constants.CONFIG.STORAGE.UPLOAD_DIR + video.filename, callback)
259} 252}
260 253
261// Maybe the torrent is not seeded, but we catch the error to don't stop the removing process 254// Maybe the torrent is not seeded, but we catch the error to don't stop the removing process
@@ -277,7 +270,7 @@ function createThumbnail (videoPath, callback) {
277 }) 270 })
278 .thumbnail({ 271 .thumbnail({
279 count: 1, 272 count: 1,
280 folder: thumbnailsDir, 273 folder: constants.CONFIG.STORAGE.THUMBNAILS_DIR,
281 size: constants.THUMBNAILS_SIZE, 274 size: constants.THUMBNAILS_SIZE,
282 filename: filename 275 filename: filename
283 }) 276 })
@@ -299,7 +292,7 @@ function generateThumbnailFromBase64 (data, callback) {
299 if (err) return callback(err) 292 if (err) return callback(err)
300 293
301 const thumbnailName = randomString + '.jpg' 294 const thumbnailName = randomString + '.jpg'
302 fs.writeFile(thumbnailsDir + thumbnailName, data, { encoding: 'base64' }, function (err) { 295 fs.writeFile(constants.CONFIG.STORAGE.THUMBNAILS_DIR + thumbnailName, data, { encoding: 'base64' }, function (err) {
303 if (err) return callback(err) 296 if (err) return callback(err)
304 297
305 return callback(null, thumbnailName) 298 return callback(null, thumbnailName)