From a85062966179da2ea8535b1d55badd0272a01734 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Tue, 12 Mar 2019 23:13:47 +0100 Subject: [PATCH] Fixed bug in AWS lib --- libs/aws.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libs/aws.js b/libs/aws.js index cb1b2d1..6c0e6d5 100644 --- a/libs/aws.js +++ b/libs/aws.js @@ -1,19 +1,16 @@ const AWS = require('aws-sdk') const fs = require('fs') const path = require('path') -const imagemin = require('imagemin') -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) @@ -35,12 +32,13 @@ class Aws { callback(null, { file: process.env.AWS_URL + dest }) + fs.unlink(params.path, () => { }) } }) }) } - _compress(params, callback) { + _compress (params, callback) { const newFile = params.path + '.' + params.filename.split('.')[1] fs.copyFile(params.path, newFile, (err, res) => { @@ -65,7 +63,7 @@ class Aws { * @param {Object} params {path: String, filename: String} * @param {Function} callback */ - upload(params, callback) { + upload (params, callback) { fs.readFile(params.path, (err, data) => { if (err) { callback(err, null) @@ -76,7 +74,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 = []