Skip to content

Commit

Permalink
Delete PDF file from S3
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtcode committed Nov 28, 2018
1 parent 15519c2 commit 1233cef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/recognizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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);
}
};
1 change: 1 addition & 0 deletions src/webSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 1233cef

Please sign in to comment.