local image storage fixes

This commit is contained in:
zadam
2020-03-25 18:21:55 +01:00
parent 8a92786012
commit ef61e22f1f
4 changed files with 18 additions and 8 deletions

View File

@@ -44,6 +44,12 @@ function getImageType(buffer) {
}
}
function getImageMimeFromExtension(ext) {
ext = ext.toLowerCase();
return 'image/' + (ext === 'svg' ? 'svg+xml' : ext);
}
async function updateImage(noteId, uploadBuffer, originalName) {
const {buffer, imageFormat} = await processImage(uploadBuffer, originalName, true);
@@ -51,7 +57,7 @@ async function updateImage(noteId, uploadBuffer, originalName) {
await noteRevisionService.createNoteRevision(note);
note.mime = 'image/' + imageFormat.ext.toLowerCase();
note.mime = getImageMimeFromExtension(imageFormat.ext);
await note.setContent(buffer);
@@ -72,7 +78,7 @@ async function saveImage(parentNoteId, uploadBuffer, originalName, shrinkImageSw
title: fileName,
content: buffer,
type: 'image',
mime: 'image/' + imageFormat.ext.toLowerCase(),
mime: getImageMimeFromExtension(imageFormat.ext),
isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable()
});