From 70d5c7a6482bce0edc8746f6f4b1b78472bfee33 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Fri, 5 Nov 2021 12:17:05 +0000 Subject: [PATCH] Server: Set resource content size when viewing published note --- packages/server/src/utils/joplinUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/utils/joplinUtils.ts b/packages/server/src/utils/joplinUtils.ts index d6f9519bbf9..4e0289191f1 100644 --- a/packages/server/src/utils/joplinUtils.ts +++ b/packages/server/src/utils/joplinUtils.ts @@ -153,7 +153,7 @@ async function noteLinkedItemInfos(userId: Uuid, itemModel: ItemModel, note: Not return output; } -async function renderResource(userId: string, resourceId: string, item: Item, content: any): Promise { +async function renderResource(userId: string, resourceId: string, item: Item, content: Buffer): Promise { // The item passed to this function is the resource blob, which is // sufficient to download the resource. However, if we want a more user // friendly download, we need to know the resource original name and mime @@ -170,7 +170,7 @@ async function renderResource(userId: string, resourceId: string, item: Item, co return { body: content, mime: jopItem ? jopItem.mime : item.mime_type, - size: item.content_size, + size: content ? content.byteLength : 0, filename: jopItem ? jopItem.title : '', }; }