added aad encryption

This commit is contained in:
Abhinav Adduri 2017-06-20 14:33:28 -07:00 committed by Danny Coates
parent 50995238bd
commit 34c367c49f
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
5 changed files with 52 additions and 10 deletions

View file

@ -78,14 +78,17 @@ app.get('/assets/download/:id', (req, res) => {
return;
}
storage
.filename(id)
.then(reply => {
Promise.all([
storage.filename(id),
storage.aad(id)])
.then(([reply, aad]) => {
storage.length(id).then(contentLength => {
res.writeHead(200, {
'Content-Disposition': 'attachment; filename=' + reply,
'Content-Type': 'application/octet-stream',
'Content-Length': contentLength
'Content-Length': contentLength,
'Additional-Data': aad
});
const file_stream = storage.get(id);
@ -142,16 +145,22 @@ app.post('/upload/:id', (req, res, next) => {
}
req.pipe(req.busboy);
req.busboy.on('field', (fieldname, value) => {
storage.setField(req.params.id, fieldname, value);
})
req.busboy.on('file', (fieldname, file, filename) => {
log.info('Uploading:', req.params.id);
const protocol = conf.env === 'production' ? 'https' : req.protocol;
const url = `${protocol}://${req.get('host')}/download/${req.params.id}/`;
storage.set(req.params.id, file, filename, url).then(linkAndID => {
res.json(linkAndID);
});
});
});
app.get('/__lbheartbeat__', (req, res) => {