attach extension to download file if note present

This commit is contained in:
zadam
2020-05-12 10:28:31 +02:00
parent cb70109ee7
commit 9d8b8e26a1
4 changed files with 53 additions and 18 deletions

View File

@@ -1,6 +1,5 @@
"use strict";
const noteService = require('../../services/notes');
const protectedSessionService = require('../../services/protected_session');
const repository = require('../../services/repository');
const utils = require('../../services/utils');
@@ -45,7 +44,9 @@ async function downloadNoteFile(noteId, res, contentDisposition = true) {
if (contentDisposition) {
// (one) reason we're not using the originFileName (available as label) is that it's not
// available for older note revisions and thus would be inconsistent
res.setHeader('Content-Disposition', utils.getContentDisposition(note.title || "untitled"));
const filename = utils.formatDownloadTitle(note.title, note.type, note.mime);
res.setHeader('Content-Disposition', utils.getContentDisposition(filename));
}
res.setHeader('Content-Type', note.mime);
@@ -70,4 +71,4 @@ module.exports = {
openFile,
downloadFile,
downloadNoteFile
};
};