dify icon indicating copy to clipboard operation
dify copied to clipboard

When I upload a document via the API, I will get the following error message: File not found

Open shengxiagit opened this issue 2 years ago • 4 comments

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.

shengxiagit avatar Oct 28 '24 07:10 shengxiagit

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:

  1. Set the STORAGE_TYPE to local:

    export STORAGE_TYPE=local
    
  2. Define the STORAGE_LOCAL_PATH:

    export STORAGE_LOCAL_PATH=/path/to/local/storage
    
  3. Mount the storage directory in your Docker setup: Ensure that the /app/api/storage directory in both containers is mounted to the same local directory. This can be done by adding the following volume configuration in your docker-compose.yml file:

    volumes:
      - /path/to/local/storage:/app/api/storage
    
  4. 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.

dosubot[bot] avatar Oct 28 '24 07:10 dosubot[bot]

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:

  1. Set the STORAGE_TYPE to local:
    export STORAGE_TYPE=local
    
  2. Define the STORAGE_LOCAL_PATH:
    export STORAGE_LOCAL_PATH=/path/to/local/storage
    
  3. Mount the storage directory in your Docker setup: Ensure that the /app/api/storage directory in both containers is mounted to the same local directory. This can be done by adding the following volume configuration in your docker-compose.yml file:
    volumes:
      - /path/to/local/storage:/app/api/storage
    
  4. 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.

But I am using aliyun-oss, not local. And the file has been successfully uploaded to aliyun-oss @dosu

shengxiagit avatar Oct 28 '24 08:10 shengxiagit

Link https://github.com/langgenius/dify/issues/10069

This one can call it but it doesn't get the file.

crazywoola avatar Nov 01 '24 02:11 crazywoola

If you're using Aliyun OSS and encountering a "File not found" error despite successful uploads, consider these potential causes and solutions:

  1. Check the api/storage/privkeys File: Ensure that the api/storage/privkeys file 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-pair
    

    This command is for Docker Compose deployment. For source code startup, run it from the API directory.

  2. 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, and ALIYUN_OSS_REGION are correctly set.

  3. 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.

  4. 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.

dosubot[bot] avatar Nov 01 '24 02:11 dosubot[bot]