|
|
|
@ -4,7 +4,8 @@ var user = require('./../user.js'),
|
|
|
|
|
fs = require('fs'),
|
|
|
|
|
utils = require('./../../public/src/utils.js'),
|
|
|
|
|
path = require('path'),
|
|
|
|
|
marked = require('marked');
|
|
|
|
|
marked = require('marked'),
|
|
|
|
|
winston = require('winston');
|
|
|
|
|
|
|
|
|
|
(function(User) {
|
|
|
|
|
User.create_routes = function(app) {
|
|
|
|
@ -136,7 +137,7 @@ var user = require('./../user.js'),
|
|
|
|
|
|
|
|
|
|
fs.unlink(absolutePath, function(err) {
|
|
|
|
|
if(err) {
|
|
|
|
|
console.error('[%d] %s', Date.now(), + err);
|
|
|
|
|
winston.error('[%d] %s', Date.now(), + err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uploadUserPicture(req.user.uid, path.extname(req.files.userPhoto.name), req.files.userPhoto.path, res);
|
|
|
|
@ -155,8 +156,7 @@ var user = require('./../user.js'),
|
|
|
|
|
var filename = uid + '-profileimg' + extension;
|
|
|
|
|
var uploadPath = path.join(global.configuration['ROOT_DIRECTORY'], global.nconf.get('upload_path'), filename);
|
|
|
|
|
|
|
|
|
|
// @todo move to proper logging code - this should only be temporary
|
|
|
|
|
console.log('Info: Attempting upload to: '+ uploadPath);
|
|
|
|
|
winston.info('Attempting upload to: '+ uploadPath);
|
|
|
|
|
|
|
|
|
|
var is = fs.createReadStream(tempPath);
|
|
|
|
|
var os = fs.createWriteStream(uploadPath);
|
|
|
|
@ -176,11 +176,7 @@ var user = require('./../user.js'),
|
|
|
|
|
height: 128
|
|
|
|
|
}, function(err, stdout, stderr){
|
|
|
|
|
if (err) {
|
|
|
|
|
// @todo: better logging method; for now, send to stderr.
|
|
|
|
|
// ideally, this should be happening in another process
|
|
|
|
|
// to avoid poisoning the main process on error or allowing a significant problem
|
|
|
|
|
// to crash the main process
|
|
|
|
|
console.error('[%d] %s', Date.now(), + err);
|
|
|
|
|
winston.err(err.message, err.stack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res.json({ path: imageUrl });
|
|
|
|
@ -189,7 +185,7 @@ var user = require('./../user.js'),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
os.on('error', function(err) {
|
|
|
|
|
console.error('[%d] %s', Date.now(), + err);
|
|
|
|
|
winston.error('[%d] %s', Date.now(), + err);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
is.pipe(os);
|
|
|
|
|