mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-17 18:17:10 +00:00
Fix encoding binary files like PDFs for sync from Desktop client
Use readFileSync, Buffer to pass appropriately formatted binary data
This commit is contained in:
parent
2646c8554d
commit
ba60c869c9
1 changed files with 4 additions and 3 deletions
|
@ -135,9 +135,10 @@ function pushDataToKhoj (regenerate = false) {
|
|||
}
|
||||
|
||||
try {
|
||||
encoding = binaryFileTypes.includes(file.split('.').pop()) ? "binary" : "utf8";
|
||||
mimeType = filenameToMimeType(file) + (encoding === "utf8" ? "; charset=UTF-8" : "");
|
||||
fileObj = new Blob([fs.createReadStream(file, encoding)], { type: mimeType });
|
||||
let encoding = binaryFileTypes.includes(file.split('.').pop()) ? "binary" : "utf8";
|
||||
let mimeType = filenameToMimeType(file) + (encoding === "utf8" ? "; charset=UTF-8" : "");
|
||||
let fileContent = Buffer.from(fs.readFileSync(file, { encoding: encoding }), encoding);
|
||||
let fileObj = new Blob([fileContent], { type: mimeType });
|
||||
formData.append('files', fileObj, file);
|
||||
state[file] = {
|
||||
success: true,
|
||||
|
|
Loading…
Reference in a new issue