From 1233cefe620520e74f851d88684822667862e0d3 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Wed, 28 Nov 2018 19:21:29 +0200 Subject: [PATCH] Delete PDF file from S3 --- src/recognizer.js | 5 +++++ src/webSession.js | 1 + 2 files changed, 6 insertions(+) diff --git a/src/recognizer.js b/src/recognizer.js index 0f8c922..dc51118 100644 --- a/src/recognizer.js +++ b/src/recognizer.js @@ -48,6 +48,10 @@ let Recognizer = module.exports = { return uploadID; }, + remove: async function(uploadID) { + await S3.deleteObject({Key: uploadID}).promise(); + }, + /** * Recognize the uploaded PDF by invoking recognizer Lambda function * @@ -192,5 +196,6 @@ let Recognizer = module.exports = { let uploadID = ctx.request.body; let item = await this.recognize(uploadID); ctx.body = Zotero.Utilities.itemToAPIJSON(item); + await this.remove(uploadID); } }; diff --git a/src/webSession.js b/src/webSession.js index ae83e45..ba4d8b9 100644 --- a/src/webSession.js +++ b/src/webSession.js @@ -163,6 +163,7 @@ WebSession.prototype.handleURL = async function () { let uploadID = await Recognizer.upload(req.response); let item = await Recognizer.recognize(uploadID); this.ctx.response.body = Zotero.Utilities.itemToAPIJSON(item); + await Recognizer.remove(uploadID); resolve(); }