From c8293998d95c36e25450b127ae84d11d1c454698 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Tue, 17 Oct 2023 15:07:05 -0700 Subject: [PATCH] Fix encoding binary files like PDFs for sync from Obsidian client Use readBinary to read binary files like PDFs instead of read --- src/interface/obsidian/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interface/obsidian/src/utils.ts b/src/interface/obsidian/src/utils.ts index ace130e3..02d7e272 100644 --- a/src/interface/obsidian/src/utils.ts +++ b/src/interface/obsidian/src/utils.ts @@ -62,7 +62,7 @@ export async function updateContentIndex(vault: Vault, setting: KhojSetting, las countOfFilesToIndex++; const encoding = binaryFileTypes.includes(file.extension) ? "binary" : "utf8"; const mimeType = fileExtensionToMimeType(file.extension) + (encoding === "utf8" ? "; charset=UTF-8" : ""); - const fileContent = await vault.read(file); + const fileContent = encoding == 'binary' ? await vault.readBinary(file) : await vault.read(file); formData.append('files', new Blob([fileContent], { type: mimeType }), file.path); }