Mintplex-Labs / anything-llm

The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, and more.
https://anythingllm.com
MIT License
26.55k stars 2.65k forks source link

[BUG]: Unable to upload documents when $STORAGE_DIR is not default #1634

Closed neight-allen closed 5 months ago

neight-allen commented 5 months ago

How are you running AnythingLLM?

Docker (remote machine)

What happened?

I'm pretty sure I know what's wrong, and I think I can fix it, but this is my first modification to the codebase and wanted πŸ‘€ on it before I open a PR.

When researching the error, I came across this: https://github.com/Mintplex-Labs/anything-llm/blob/1b8386b079cdb2524212ce6ff99dc1e3ea092c1d/server/utils/files/multer.js#L10-L12

I think the collector folder should not be relative to storage. I expect the path should be resolved as it is on L11 regardless of environment.

Are there known steps to reproduce?

Fails with error:

Invalid file upload. ENOENT: no such file or directory, open '/home/app/collector/hotdir/filename.pdf'"

I did this in Azure App Service as a custom container deployment. In order to persist storage across restarts, it needs to be in the /home directory.

timothycarambat commented 5 months ago

The reason it is like this is that it works without us having to maintain a branch for hosting, docker, and desktop. But the downside is that it requires these options when booting in docker:

...
-v ${STORAGE_LOCATION}:/app/server/storage \
-v ${STORAGE_LOCATION}/.env:/app/server/.env \
-e STORAGE_DIR="/app/server/storage" \
...

Ref: https://github.com/Mintplex-Labs/anything-llm/blob/master/docker/HOW_TO_USE_DOCKER.md

If you change that the amount of headaches that will result will be innumerable πŸ˜“