v1.18.x
barisusakli 10 years ago
parent b1b25ada4d
commit 1d1625f5c4

@ -25,7 +25,7 @@ var fs = require('fs'),
function userNotFound(res) {
res.locals.notFound = true;
if (res.locals.isAPI) {
res.status(404).json('no-user');
} else {
@ -489,7 +489,7 @@ accountsController.uploadPicture = function (req, res, next) {
user.getUserField(updateUid, 'uploadedpicture', function (err, oldpicture) {
if (!oldpicture) {
file.saveFileToLocal(filename, req.files.userPhoto.path, done);
file.saveFileToLocal(filename, 'profile', req.files.userPhoto.path, done);
return;
}
@ -500,7 +500,7 @@ accountsController.uploadPicture = function (req, res, next) {
winston.err(err);
}
file.saveFileToLocal(filename, req.files.userPhoto.path, done);
file.saveFileToLocal(filename, 'profile', req.files.userPhoto.path, done);
});
});
});

@ -23,7 +23,7 @@ function validateUpload(res, req, allowedTypes) {
uploadsController.uploadImage = function(filename, req, res) {
uploadsController.uploadImage = function(filename, folder, req, res) {
function done(err, image) {
var er, rs;
fs.unlink(req.files.userPhoto.path);
@ -40,7 +40,7 @@ uploadsController.uploadImage = function(filename, req, res) {
if(plugins.hasListeners('filter:uploadImage')) {
plugins.fireHook('filter:uploadImage', req.files.userPhoto, done);
} else {
file.saveFileToLocal(filename, req.files.userPhoto.path, done);
file.saveFileToLocal(filename, folder, req.files.userPhoto.path, done);
}
};
@ -59,7 +59,7 @@ uploadsController.uploadCategoryPicture = function(req, res, next) {
if (validateUpload(res, req, allowedTypes)) {
var filename = 'category-' + params.cid + path.extname(req.files.userPhoto.name);
uploadsController.uploadImage(filename, req, res);
uploadsController.uploadImage(filename, 'category', req, res);
}
};
@ -67,7 +67,7 @@ uploadsController.uploadFavicon = function(req, res, next) {
var allowedTypes = ['image/x-icon', 'image/vnd.microsoft.icon'];
if (validateUpload(res, req, allowedTypes)) {
file.saveFileToLocal('favicon.ico', req.files.userPhoto.path, function(err, image) {
file.saveFileToLocal('favicon.ico', 'files', req.files.userPhoto.path, function(err, image) {
fs.unlink(req.files.userPhoto.path);
if(err) {
@ -93,7 +93,7 @@ function upload(name, req, res, next) {
if (validateUpload(res, req, allowedTypes)) {
var filename = name + path.extname(req.files.userPhoto.name);
uploadsController.uploadImage(filename, req, res);
uploadsController.uploadImage(filename, 'files', req, res);
}
}

@ -7,9 +7,9 @@ var fs = require('fs'),
var file = {};
file.saveFileToLocal = function(filename, tempPath, callback) {
file.saveFileToLocal = function(filename, folder, tempPath, callback) {
var uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), filename);
var uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), folder, filename);
winston.info('Saving file '+ filename +' to : ' + uploadPath);

@ -115,7 +115,7 @@ function uploadFile(file, callback) {
}
var filename = 'upload-' + utils.generateUUID() + path.extname(file.name);
require('../file').saveFileToLocal(filename, file.path, function(err, upload) {
require('../file').saveFileToLocal(filename, 'files', file.path, function(err, upload) {
if(err) {
return callback(err);
}

Loading…
Cancel
Save