Fix encoding binary files like PDFs for sync from Obsidian client

Use readBinary to read binary files like PDFs instead of read
This commit is contained in:
Debanjum Singh Solanky 2023-10-17 15:07:05 -07:00
parent ba60c869c9
commit c8293998d9

View file

@ -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);
}