mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-09-08 20:51:06 +02:00
fix(users): Better MIME-type checking, remove image cropping library (#1589)
* Cropping remove, nicer UI * Fix MIME-type checking, add image upload tests * Change image config settings to uploads.profile.image to build a more rational structure for configuring other types of uploads
This commit is contained in:
committed by
Michael Leanos
parent
e62b6808e0
commit
2b6cf53d30
@@ -56,12 +56,12 @@ exports.update = function (req, res) {
|
||||
*/
|
||||
exports.changeProfilePicture = function (req, res) {
|
||||
var user = req.user;
|
||||
var upload = multer(config.uploads.profileUpload).single('newProfilePicture');
|
||||
var profileUploadFileFilter = require(path.resolve('./config/lib/multer')).profileUploadFileFilter;
|
||||
var existingImageUrl;
|
||||
|
||||
// Filtering to upload only images
|
||||
upload.fileFilter = profileUploadFileFilter;
|
||||
var multerConfig = config.uploads.profile.image;
|
||||
multerConfig.fileFilter = require(path.resolve('./config/lib/multer')).imageFileFilter;
|
||||
var upload = multer(multerConfig).single('newProfilePicture');
|
||||
|
||||
if (user) {
|
||||
existingImageUrl = user.profileImageURL;
|
||||
@@ -95,7 +95,7 @@ exports.changeProfilePicture = function (req, res) {
|
||||
|
||||
function updateUser () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
user.profileImageURL = config.uploads.profileUpload.dest + req.file.filename;
|
||||
user.profileImageURL = config.uploads.profile.image.dest + req.file.filename;
|
||||
user.save(function (err, theuser) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
|
||||
Reference in New Issue
Block a user