diff --git a/libs/aws.js b/libs/aws.js index 4f2dada..cb1b2d1 100644 --- a/libs/aws.js +++ b/libs/aws.js @@ -6,14 +6,14 @@ const imageminJpegtran = require('imagemin-jpegtran') const imageminPngquant = require('imagemin-pngquant') class Aws { - constructor () { + constructor() { AWS.config.update({ accessKeyId: process.env.AWS_ACCESS_KEY_ID, secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY }) } - _send (params, callback) { + _send(params, callback) { fs.readFile(params.path, (err, data) => { if (err) { callback(err, null) @@ -40,42 +40,23 @@ class Aws { }) } - _compress (params, callback) { + _compress(params, callback) { const newFile = params.path + '.' + params.filename.split('.')[1] fs.copyFile(params.path, newFile, (err, res) => { - console.log('_compress => copyFile') if (err) { callback(err, null) return false } - try { - (async () => { - // const file = await imagemin([newFile], '/tmp', { - // plugins: [ - // imageminJpegtran(), - // imageminPngquant({ - // quality: '65-80' - // }) - // ] - // }) - - // console.log('Après imagemin') - - this._send({ - path: newFile, - // path: file[0].path, - filename: params.filename - }, (err, res) => { - callback(err, res) - // fs.unlink(file[0].path, () => { }) - }) - })() - } catch (e) { - console.log('Error:', e) - callback(e) - } + this._send({ + path: newFile, + // path: file[0].path, + filename: params.filename + }, (err, res) => { + callback(err, res) + // fs.unlink(file[0].path, () => { }) + }) }) } @@ -84,9 +65,8 @@ class Aws { * @param {Object} params {path: String, filename: String} * @param {Function} callback */ - upload (params, callback) { + upload(params, callback) { fs.readFile(params.path, (err, data) => { - console.log('après upload -> readfile') if (err) { callback(err, null) return false @@ -96,7 +76,7 @@ class Aws { }) } - deleteObjects (files, callback) { + deleteObjects(files, callback) { const s3 = new AWS.S3() const basePath = process.env.AWS_URL + process.env.AWS_BASEFOLDER let items = [] diff --git a/libs/resize.js b/libs/resize.js index 7e9241b..0f70d9e 100644 --- a/libs/resize.js +++ b/libs/resize.js @@ -19,7 +19,6 @@ class Resize { _resize (input, output, callback) { fs.readFile(input, (err, data) => { - console.log('après readfile') if (err) { callback(err, null) return false @@ -27,9 +26,7 @@ class Resize { resizeImg(data, this.size) .then(buf => { - console.log('then rezise') fs.writeFile(output, buf, (err) => { - console.log('write file') if (err) { callback(err, null) return false diff --git a/middleware/Pictures.js b/middleware/Pictures.js index 1c09430..8caf0e4 100644 --- a/middleware/Pictures.js +++ b/middleware/Pictures.js @@ -165,10 +165,7 @@ class Pictures { fs.unlink(large.output, () => { }) - console.log('avant thumb') - resize.createThumbnail(req.file.path, (err, file) => { - console.log('après createThumb') if (err) { callback(err, null) return false @@ -178,7 +175,6 @@ class Pictures { path: file.output, filename: `picture_${req.params.vegetablesId}_${key}_thumb.${req.file.originalname.split('.')[req.file.originalname.split('.').length - 1]}` }, (err, res) => { - console.log('après upload') if (err) { callback(err, null) } this._createOne(req, callback) diff --git a/middleware/VegetableProperties.js b/middleware/VegetableProperties.js index 874d2a9..9bc8237 100644 --- a/middleware/VegetableProperties.js +++ b/middleware/VegetableProperties.js @@ -85,7 +85,6 @@ class VegetableProperties { callback(null, null) }) .catch(e => { - console.log('this case?') callback(e, null) }) })