mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-15 19:00:33 +01:00
c4eb46ca19
* implement dnd uploader show file upload progress write files to hotdirector build simple flaskAPI to process files one off * move document processor calls to util build out dockerfile to run both procs at the same time update UI to check for document processor before upload * disable pragma update on boot * dockerfile changes * add filetype restrictions based on python app support response and show rejected files in the UI * cleanup * stub migrations on boot to prevent exit condition * update CF template for AWS deploy
27 lines
863 B
JavaScript
27 lines
863 B
JavaScript
async function fileUploadProgress(request, response, next) {
|
|
let progress = 0;
|
|
const fileSize = request.headers["content-length"]
|
|
? parseInt(request.headers["content-length"])
|
|
: 0;
|
|
|
|
// Note(tcarambat): While this is chunked it does not stream back to the UI for some reason.
|
|
// It just waits for the entire requests to finish. Likely because it is not using EventSource on frontend
|
|
// which is limited to GET.
|
|
// TODO: Someone smarter than me add streaming here to report back real-time progress.
|
|
response.writeHead(200);
|
|
request.on("data", (chunk) => {
|
|
progress += chunk.length;
|
|
const percentage = (progress / fileSize) * 100;
|
|
response.write(`${JSON.stringify({ progress, fileSize, percentage })}\n`);
|
|
if (progress >= fileSize) {
|
|
response.end();
|
|
}
|
|
});
|
|
|
|
next();
|
|
}
|
|
|
|
module.exports = {
|
|
fileUploadProgress,
|
|
};
|