bug fixes for custom handlers

This commit is contained in:
zadam
2019-01-27 15:47:40 +01:00
parent fb27088fcd
commit b39f6ef7ad
3 changed files with 26 additions and 11 deletions

View File

@@ -34,8 +34,7 @@ async function uploadFile(req) {
};
}
async function downloadFile(req, res) {
const noteId = req.params.noteId;
async function downloadNoteFile(noteId, res) {
const note = await repository.getNote(noteId);
if (!note) {
@@ -43,8 +42,7 @@ async function downloadFile(req, res) {
}
if (note.isProtected && !protectedSessionService.isProtectedSessionAvailable()) {
res.status(401).send("Protected session not available");
return;
return res.status(401).send("Protected session not available");
}
const originalFileName = await note.getLabel('originalFileName');
@@ -56,7 +54,15 @@ async function downloadFile(req, res) {
res.send(note.content);
}
async function downloadFile(req, res) {
const noteId = req.params.noteId;
return await downloadNoteFile(noteId, res);
}
module.exports = {
uploadFile,
downloadFile
downloadFile,
downloadNoteFile
};