mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Share any file type from web client. Let server decide if its supported
This commit is contained in:
parent
ed693afd68
commit
2d35004371
1 changed files with 2 additions and 21 deletions
|
@ -925,25 +925,8 @@ To get started, just start typing below. You can also type / to see a list of co
|
|||
|
||||
function uploadDataForIndexing(files) {
|
||||
var dropzone = document.getElementById('chat-body');
|
||||
var badfiles = [];
|
||||
var goodfiles = [];
|
||||
var overlayText = document.getElementById("dropzone-overlay");
|
||||
|
||||
for (let file of files) {
|
||||
if (!file || (!allowedExtensions.includes(file.type) && !allowedFileEndings.includes(file.name.split('.').pop()))) {
|
||||
if (file) {
|
||||
badfiles.push(file.name);
|
||||
}
|
||||
} else {
|
||||
goodfiles.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (badfiles.length > 0) {
|
||||
alert("The following files are not supported yet:\n" + badfiles.join('\n'));
|
||||
}
|
||||
|
||||
|
||||
const formData = new FormData();
|
||||
var overlayText = document.getElementById("dropzone-overlay");
|
||||
if (overlayText != null) {
|
||||
|
@ -955,7 +938,7 @@ To get started, just start typing below. You can also type / to see a list of co
|
|||
}
|
||||
|
||||
// Create an array of Promises for file reading
|
||||
const fileReadPromises = Array.from(goodfiles).map(file => {
|
||||
const fileReadPromises = Array.from(files).map(file => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let reader = new FileReader();
|
||||
reader.onload = function (event) {
|
||||
|
@ -980,9 +963,7 @@ To get started, just start typing below. You can also type / to see a list of co
|
|||
fileType = "image/png";
|
||||
}
|
||||
else {
|
||||
// Skip this file if its type is not supported
|
||||
resolve();
|
||||
return;
|
||||
fileType = "text/plain";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue