When I upload a document via the API, I will get the following error message: File not found
Self Checks
- [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
Dify version
0.9.2 - 0.10.1
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
I did not capture any error logs in docker. I use aliyun-oss as file storage.
✔️ Expected Behavior
process document success
❌ Actual Behavior
I use aliyun-oss as file storage. When I upload a document via the API, I will get the following error message: File not found. But When I click the retry button it works fine.
I found a similar closed issue regarding a "File not found" error when uploading a file in a self-hosted Dify setup using Docker. The suggested solution involves ensuring that the local storage path is correctly configured and mounted. Here are the steps you can follow:
-
Set the
STORAGE_TYPEtolocal:export STORAGE_TYPE=local -
Define the
STORAGE_LOCAL_PATH:export STORAGE_LOCAL_PATH=/path/to/local/storage -
Mount the storage directory in your Docker setup: Ensure that the
/app/api/storagedirectory in both containers is mounted to the same local directory. This can be done by adding the following volume configuration in yourdocker-compose.ymlfile:volumes: - /path/to/local/storage:/app/api/storage -
Restart your Docker containers:
docker-compose down docker-compose up -d
Additionally, ensure that the storage directory has the appropriate permissions and ownership settings to allow the Docker container to read from and write to it. Another user mentioned that attaching a NAS as a PVC solved the problem, indicating that shared storage between containers is necessary [1].
To continue talking to Dosu, mention @dosu.
I found a similar closed issue regarding a "File not found" error when uploading a file in a self-hosted Dify setup using Docker. The suggested solution involves ensuring that the local storage path is correctly configured and mounted. Here are the steps you can follow:
- Set the
STORAGE_TYPEtolocal:export STORAGE_TYPE=local- Define the
STORAGE_LOCAL_PATH:export STORAGE_LOCAL_PATH=/path/to/local/storage- Mount the storage directory in your Docker setup: Ensure that the
/app/api/storagedirectory in both containers is mounted to the same local directory. This can be done by adding the following volume configuration in yourdocker-compose.ymlfile:volumes: - /path/to/local/storage:/app/api/storage- Restart your Docker containers:
docker-compose down docker-compose up -dAdditionally, ensure that the storage directory has the appropriate permissions and ownership settings to allow the Docker container to read from and write to it. Another user mentioned that attaching a NAS as a PVC solved the problem, indicating that shared storage between containers is necessary [1].
To continue talking to Dosu, mention @dosu.
But I am using aliyun-oss, not local. And the file has been successfully uploaded to aliyun-oss @dosu
Link https://github.com/langgenius/dify/issues/10069
This one can call it but it doesn't get the file.
If you're using Aliyun OSS and encountering a "File not found" error despite successful uploads, consider these potential causes and solutions:
-
Check the
api/storage/privkeysFile: Ensure that theapi/storage/privkeysfile is not deleted or missing. This file is crucial for encrypting large model keys, and its absence can lead to errors. If it's lost, you can reset the encryption keys using:docker exec -it docker-api-1 flask reset-encrypt-key-pairThis command is for Docker Compose deployment. For source code startup, run it from the API directory.
-
Verify Configuration Settings: Double-check your Aliyun OSS configuration settings in your environment variables. Ensure that all required parameters like
ALIYUN_OSS_BUCKET_NAME,ALIYUN_OSS_ACCESS_KEY,ALIYUN_OSS_SECRET_KEY,ALIYUN_OSS_ENDPOINT, andALIYUN_OSS_REGIONare correctly set. -
Check for Consistency: Ensure that the file paths and names used in your application match those in Aliyun OSS. Any discrepancies can cause the application to not find the file even if it exists in the storage.
-
Retry Mechanism: Since you mentioned that retrying works, there might be a timing issue or a temporary connectivity problem. Implementing a retry mechanism in your application logic might help mitigate this issue.
These steps should help address the "File not found" error when using Aliyun OSS with Dify [1][2].
To continue talking to Dosu, mention @dosu.