|
|
|
@ -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, {
|
|
|
|
|