langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
52.6k stars 7.69k forks source link

The official API documentation I read should be like this for uploading files. When I use the file list, I can only upload one file. When I use a single file, it reports the following error. Can't the API be written better? #10974

Closed Vampxgg closed 3 days ago

Vampxgg commented 3 days ago

Self Checks

Dify version

0.11.2

Cloud or Self Hosted

Cloud

Steps to reproduce

232f151e-655b-4d4e-bd89-4e40055526c0

✔️ Expected Behavior

1

❌ Actual Behavior

1

dosubot[bot] commented 3 days ago

I found some similar discussions and issues related to file uploads in Dify:

  1. How can I upload with multiple files to another server to handle? - This discussion is unsolved and might provide some insights into handling multiple file uploads [1].

  2. I can't upload the image on dify workflow via api - Another unsolved discussion that might be relevant to your issue [2].

  3. The document upload behavior of web and API is inconsistent! - This closed issue suggests ensuring consistent document upload behavior by sharing the same storage volume between API and worker services in the docker-compose.yaml file [3].

For uploading multiple files using the API without encountering errors, you can use a function like uploadMultipleFiles to handle batch uploads. This involves preparing and validating files, then uploading them in batches to avoid errors. Make sure to handle potential errors such as FileTooLargeError, NoFileUploadedError, TooManyFilesError, and UnsupportedFileTypeError [4][5][6].

If you're encountering issues with single file uploads, ensure that the file is correctly included in the form data of your request. The error message "file is required in input form" with status 400 indicates that the file was not properly included. Make sure the request is formatted as multipart/form-data and that the file type is supported [7].

To continue talking to Dosu, mention @dosu.

crazywoola commented 3 days ago

You can not even choose a right template. If you choose files, then it should be an array. If this is an single file type, it should not.