v1.18.x
barisusakli 9 years ago
parent 16ba7ee840
commit 630dd66cf6

@ -198,7 +198,7 @@ function uploadFile(uid, uploadedFile, callback) {
function saveFileToLocal(uploadedFile, callback) {
var extension = path.extname(uploadedFile.name);
if (!extension) {
if (!extension && uploadedFile.type) {
extension = '.' + mime.extension(uploadedFile.type);
}

@ -6,6 +6,7 @@ var path = require('path');
var fs = require('fs');
var crypto = require('crypto');
var Jimp = require('jimp');
var mime = require('mime');
var db = require('../database');
var file = require('../file');
@ -29,6 +30,7 @@ module.exports = function(Groups) {
var tempPath = data.file ? data.file : '';
var url;
var type = data.file ? mime.lookup(data.file) : 'image/png';
async.waterfall([
function (next) {
@ -41,7 +43,8 @@ module.exports = function(Groups) {
tempPath = _tempPath;
uploadsController.uploadGroupCover(uid, {
name: 'groupCover',
path: tempPath
path: tempPath,
type: type
}, next);
},
function (uploadData, next) {
@ -54,7 +57,8 @@ module.exports = function(Groups) {
function (next) {
uploadsController.uploadGroupCover(uid, {
name: 'groupCoverThumb',
path: tempPath
path: tempPath,
type: type
}, next);
},
function (uploadData, next) {
@ -104,7 +108,7 @@ module.exports = function(Groups) {
md5sum = md5sum.digest('hex');
// Save image
var tempPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), md5sum);
var tempPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), md5sum) + '.png';
var buffer = new Buffer(imageData.slice(imageData.indexOf('base64') + 7), 'base64');
fs.writeFile(tempPath, buffer, {

Loading…
Cancel
Save