diff --git a/config.sample.js b/config.sample.js index 903a97f..89b83a2 100644 --- a/config.sample.js +++ b/config.sample.js @@ -20,6 +20,7 @@ module.exports = { // Files will be served at http://localhost:9999/Fxt0.png { domain: 'localhost:9999' } + ], // Port on which to run the server @@ -31,7 +32,7 @@ module.exports = { // Folder where images should be stored folder: 'uploads', - // Max file size allowed + // Max file size allowed. Needs to be in MB maxSize: '512MB', // The length of the random generated name for the uploaded files diff --git a/controllers/albumsController.js b/controllers/albumsController.js index 16efd9c..9c666be 100644 --- a/controllers/albumsController.js +++ b/controllers/albumsController.js @@ -21,7 +21,7 @@ albumsController.list = function(req, res, next){ let ids = [] for(let album of albums){ album.date = new Date(album.timestamp * 1000) - album.date = album.date.getFullYear() + '-' + album.date.getMonth() + '-' + album.date.getDate() + ' ' + (album.date.getHours() < 10 ? '0' : '') + album.date.getHours() + ':' + (album.date.getMinutes() < 10 ? '0' : '') + album.date.getMinutes() + ':' + (album.date.getSeconds() < 10 ? '0' : '') + album.date.getSeconds() + album.date = album.date.getFullYear() + '-' + (album.date.getMonth() + 1) + '-' + album.date.getDate() + ' ' + (album.date.getHours() < 10 ? '0' : '') + album.date.getHours() + ':' + (album.date.getMinutes() < 10 ? '0' : '') + album.date.getMinutes() + ':' + (album.date.getSeconds() < 10 ? '0' : '') + album.date.getSeconds() ids.push(album.id) } diff --git a/controllers/uploadController.js b/controllers/uploadController.js index 4585087..6b962c3 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -93,10 +93,17 @@ uploadsController.list = function(req, res){ .then((files) => { db.table('albums').then((albums) => { + let basedomain = req.get('host') + for(let domain of config.domains) + if(domain.host === req.get('host')) + if(domain.hasOwnProperty('resolve')) + basedomain = domain.resolve + for(let file of files){ - file.file = config.basedomain + config.uploads.prefix + file.name + file.file = 'http://' + basedomain + '/' + file.name + //file.file = config.basedomain + config.uploads.prefix + file.name file.date = new Date(file.timestamp * 1000) - file.date = file.date.getFullYear() + '-' + file.date.getMonth() + '-' + file.date.getDate() + ' ' + (file.date.getHours() < 10 ? '0' : '') + file.date.getHours() + ':' + (file.date.getMinutes() < 10 ? '0' : '') + file.date.getMinutes() + ':' + (file.date.getSeconds() < 10 ? '0' : '') + file.date.getSeconds() + file.date = file.date.getFullYear() + '-' + (file.date.getMonth() + 1) + '-' + file.date.getDate() + ' ' + (file.date.getHours() < 10 ? '0' : '') + file.date.getHours() + ':' + (file.date.getMinutes() < 10 ? '0' : '') + file.date.getMinutes() + ':' + (file.date.getSeconds() < 10 ? '0' : '') + file.date.getSeconds() file.album = ''