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? #6886

Closed
opened 2026-02-21 18:17:49 -05:00 by yindo · 3 comments
Owner

Originally created by @Vampxgg on GitHub (Nov 22, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.11.2

Cloud or Self Hosted

Cloud

Steps to reproduce

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

✔️ Expected Behavior

1

Actual Behavior

1

Originally created by @Vampxgg on GitHub (Nov 22, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.11.2 ### Cloud or Self Hosted Cloud ### Steps to reproduce ![232f151e-655b-4d4e-bd89-4e40055526c0](https://github.com/user-attachments/assets/349ed977-d536-4188-b6b3-f28646d5ed1d) ### ✔️ Expected Behavior 1 ### ❌ Actual Behavior 1
yindo added the 🐞 bug📚 documentationcloud labels 2026-02-21 18:17:49 -05:00
yindo closed this issue 2026-02-21 18:17:49 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 22, 2024):

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.

@dosubot[bot] commented on GitHub (Nov 22, 2024): <!-- Answer --> 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?](https://github.com/langgenius/dify/discussions/10409) - This discussion is unsolved and might provide some insights into handling multiple file uploads <sup>[[1]](https://github.com/langgenius/dify/discussions/10409)</sup>. 2. [I can't upload the image on dify workflow via api](https://github.com/langgenius/dify/discussions/7482) - Another unsolved discussion that might be relevant to your issue <sup>[[2]](https://github.com/langgenius/dify/discussions/7482)</sup>. 3. [The document upload behavior of web and API is inconsistent!](https://github.com/langgenius/dify/issues/9177) - 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 <sup>[[3]](https://github.com/langgenius/dify/issues/9177)</sup>. 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` <sup>[[4]](https://github.com/langgenius/dify/blob/main/web/app/components/datasets/create/file-uploader/index.tsx)</sup><sup>[[5]](https://github.com/langgenius/dify/blob/main/api/controllers/console/files.py)</sup><sup>[[6]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/knowledge-base/maintain-dataset-via-api.md)</sup>. 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 <sup>[[7]](https://github.com/langgenius/dify/issues/10658)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Nov 22, 2024):

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.

@crazywoola commented on GitHub (Nov 22, 2024): 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.
Author
Owner

@Vampxgg commented on GitHub (Nov 25, 2024):

9cd3561c-7f1c-45d4-a7af-a4f79636ea7c
I specified the file list format, but why does it always show that only one file has been uploaded when I test it with apifox? ?

@Vampxgg commented on GitHub (Nov 25, 2024): ![9cd3561c-7f1c-45d4-a7af-a4f79636ea7c](https://github.com/user-attachments/assets/05c41f93-2ad3-4cbb-8846-02804e6f1f1c) I specified the file list format, but why does it always show that only one file has been uploaded when I test it with apifox? ?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6886