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') const imageminPngquant = require('imagemin-pngquant')
class Aws { class Aws {
constructor () { constructor() {
AWS.config.update({ AWS.config.update({
accessKeyId: process.env.AWS_ACCESS_KEY_ID, accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
}) })
} }
_send (params, callback) { _send(params, callback) {
fs.readFile(params.path, (err, data) => { fs.readFile(params.path, (err, data) => {
if (err) { if (err) {
callback(err, null) callback(err, null)
@ -40,29 +40,15 @@ class Aws {
}) })
} }
_compress (params, callback) { _compress(params, callback) {
const newFile = params.path + '.' + params.filename.split('.')[1] const newFile = params.path + '.' + params.filename.split('.')[1]
fs.copyFile(params.path, newFile, (err, res) => { fs.copyFile(params.path, newFile, (err, res) => {
console.log('_compress => copyFile')
if (err) { if (err) {
callback(err, null) callback(err, null)
return false return false
} }
try {
(async () => {
// const file = await imagemin([newFile], '/tmp', {
// plugins: [
// imageminJpegtran(),
// imageminPngquant({
// quality: '65-80'
// })
// ]
// })
// console.log('Après imagemin')
this._send({ this._send({
path: newFile, path: newFile,
// path: file[0].path, // path: file[0].path,
@ -71,11 +57,6 @@ class Aws {
callback(err, res) callback(err, res)
// fs.unlink(file[0].path, () => { }) // fs.unlink(file[0].path, () => { })
}) })
})()
} catch (e) {
console.log('Error:', e)
callback(e)
}
}) })
} }
@ -84,9 +65,8 @@ class Aws {
* @param {Object} params {path: String, filename: String} * @param {Object} params {path: String, filename: String}
* @param {Function} callback * @param {Function} callback
*/ */
upload (params, callback) { upload(params, callback) {
fs.readFile(params.path, (err, data) => { fs.readFile(params.path, (err, data) => {
console.log('après upload -> readfile')
if (err) { if (err) {
callback(err, null) callback(err, null)
return false return false
@ -96,7 +76,7 @@ class Aws {
}) })
} }
deleteObjects (files, callback) { deleteObjects(files, callback) {
const s3 = new AWS.S3() const s3 = new AWS.S3()
const basePath = process.env.AWS_URL + process.env.AWS_BASEFOLDER const basePath = process.env.AWS_URL + process.env.AWS_BASEFOLDER
let items = [] let items = []

View file

@ -19,7 +19,6 @@ class Resize {
_resize (input, output, callback) { _resize (input, output, callback) {
fs.readFile(input, (err, data) => { fs.readFile(input, (err, data) => {
console.log('après readfile')
if (err) { if (err) {
callback(err, null) callback(err, null)
return false return false
@ -27,9 +26,7 @@ class Resize {
resizeImg(data, this.size) resizeImg(data, this.size)
.then(buf => { .then(buf => {
console.log('then rezise')
fs.writeFile(output, buf, (err) => { fs.writeFile(output, buf, (err) => {
console.log('write file')
if (err) { if (err) {
callback(err, null) callback(err, null)
return false return false

View file

@ -165,10 +165,7 @@ class Pictures {
fs.unlink(large.output, () => { }) fs.unlink(large.output, () => { })
console.log('avant thumb')
resize.createThumbnail(req.file.path, (err, file) => { resize.createThumbnail(req.file.path, (err, file) => {
console.log('après createThumb')
if (err) { if (err) {
callback(err, null) callback(err, null)
return false return false
@ -178,7 +175,6 @@ class Pictures {
path: file.output, path: file.output,
filename: `picture_${req.params.vegetablesId}_${key}_thumb.${req.file.originalname.split('.')[req.file.originalname.split('.').length - 1]}` filename: `picture_${req.params.vegetablesId}_${key}_thumb.${req.file.originalname.split('.')[req.file.originalname.split('.').length - 1]}`
}, (err, res) => { }, (err, res) => {
console.log('après upload')
if (err) { callback(err, null) } if (err) { callback(err, null) }
this._createOne(req, callback) this._createOne(req, callback)

View file

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