Removed console.log

This commit is contained in:
dbroqua 2019-03-12 23:11:28 +01:00
parent 8b8f20a6d1
commit 823e6f0de3
4 changed files with 13 additions and 41 deletions

View file

@ -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 = []

View file

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

View file

@ -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)

View file

@ -85,7 +85,6 @@ class VegetableProperties {
callback(null, null)
})
.catch(e => {
console.log('this case?')
callback(e, null)
})
})