mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
smaller refactorings
This commit is contained in:
@@ -20,21 +20,17 @@ async function saveImage(file, noteId) {
|
||||
const fileNameWithouExtension = file.originalname.replace(/\.[^/.]+$/, "");
|
||||
const fileName = sanitizeFilename(fileNameWithouExtension + "." + imageFormat.ext);
|
||||
|
||||
const image = new Image({
|
||||
const image = await new Image({
|
||||
format: imageFormat.ext,
|
||||
name: fileName,
|
||||
checksum: utils.hash(optimizedImage),
|
||||
data: optimizedImage
|
||||
});
|
||||
}).save();
|
||||
|
||||
await image.save();
|
||||
|
||||
const noteImage = new NoteImage({
|
||||
await new NoteImage({
|
||||
noteId: noteId,
|
||||
imageId: image.imageId
|
||||
});
|
||||
|
||||
await noteImage.save();
|
||||
}).save();
|
||||
|
||||
return {fileName, imageId: image.imageId};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user