File upload API cannot upload anything other than documents #6566

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

Originally created by @fujita-h on GitHub (Nov 5, 2024).

Originally assigned to: @laipz8200 on GitHub.

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

Cloud or Self Hosted

Cloud

Steps to reproduce

  1. Create simple chatflow app.
  2. Set up the start node to enable file upload.
  3. Publish app.
  4. Enable API access and create api key.
  5. Upload image via /v1/files/upload.

✔️ Expected Behavior

The upload is successful.

Actual Behavior

Retrun error:

{"code": "unsupported_file_type", "message": "File type not allowed.", "status": 415}
Originally created by @fujita-h on GitHub (Nov 5, 2024). Originally assigned to: @laipz8200 on GitHub. ### 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.0 ### Cloud or Self Hosted Cloud ### Steps to reproduce 1. Create simple chatflow app. 2. Set up the start node to enable file upload. 3. Publish app. 4. Enable API access and create api key. 5. Upload image via `/v1/files/upload`. ### ✔️ Expected Behavior The upload is successful. ### ❌ Actual Behavior Retrun error: ``` {"code": "unsupported_file_type", "message": "File type not allowed.", "status": 415} ```
yindo added the 🐞 bug label 2026-02-21 18:16:20 -05:00
yindo closed this issue 2026-02-21 18:16:20 -05:00
Author
Owner

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

I found some relevant information regarding the "unsupported_file_type" error when uploading files other than documents. This error typically occurs when the file extension is not included in the allowed list of file types for the upload API.

For images, ensure that the file extension is one of the supported types: JPG, JPEG, PNG, WEBP, GIF, or SVG. The API checks if the file extension is part of the allowed extensions, and if not, it raises an UnsupportedFileTypeError [1].

Additionally, the supported MIME types for images are image/jpeg, image/png, image/gif, and image/webp. If your image file does not match these types, it will result in an "unsupported_file_type" error [1].

If your file meets these criteria and you are still encountering issues, it might be worth checking the configuration settings to ensure they are correctly set up to allow these file types.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Nov 5, 2024): <!-- Answer --> I found some relevant information regarding the "unsupported_file_type" error when uploading files other than documents. This error typically occurs when the file extension is not included in the allowed list of file types for the upload API. For images, ensure that the file extension is one of the supported types: JPG, JPEG, PNG, WEBP, GIF, or SVG. The API checks if the file extension is part of the allowed extensions, and if not, it raises an `UnsupportedFileTypeError` <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/services/file_service.py)</sup>. Additionally, the supported MIME types for images are `image/jpeg`, `image/png`, `image/gif`, and `image/webp`. If your image file does not match these types, it will result in an "unsupported_file_type" error <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/services/file_service.py)</sup>. If your file meets these criteria and you are still encountering issues, it might be worth checking the configuration settings to ensure they are correctly set up to allow these file types. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@fujita-h commented on GitHub (Nov 5, 2024):

In the Files API, params are passed to the File Service:
https://github.com/langgenius/dify/blob/d7b4d0756e8a538c582ee4d5a57f0830ec305c93/api/controllers/service_api/app/file.py#L39-L45

The following line will be executed because source is datasets.
https://github.com/langgenius/dify/blob/d7b4d0756e8a538c582ee4d5a57f0830ec305c93/api/services/file_service.py#L45-L46
This will cause anything other than the document file to be rejected.

These changes are from #9906.

@fujita-h commented on GitHub (Nov 5, 2024): In the Files API, params are passed to the File Service: https://github.com/langgenius/dify/blob/d7b4d0756e8a538c582ee4d5a57f0830ec305c93/api/controllers/service_api/app/file.py#L39-L45 The following line will be executed because `source` is `datasets`. https://github.com/langgenius/dify/blob/d7b4d0756e8a538c582ee4d5a57f0830ec305c93/api/services/file_service.py#L45-L46 This will cause anything other than the document file to be rejected. These changes are from #9906.
Author
Owner

@silverriver commented on GitHub (Nov 12, 2024):

Why?Why not letting user to upload non-document?

In the Files API, params are passed to the File Service:

https://github.com/langgenius/dify/blob/d7b4d0756e8a538c582ee4d5a57f0830ec305c93/api/controllers/service_api/app/file.py#L39-L45

The following line will be executed because source is datasets.

https://github.com/langgenius/dify/blob/d7b4d0756e8a538c582ee4d5a57f0830ec305c93/api/services/file_service.py#L45-L46

This will cause anything other than the document file to be rejected.
These changes are from #9906.

@silverriver commented on GitHub (Nov 12, 2024): Why?Why not letting user to upload non-document? > In the Files API, params are passed to the File Service: > > https://github.com/langgenius/dify/blob/d7b4d0756e8a538c582ee4d5a57f0830ec305c93/api/controllers/service_api/app/file.py#L39-L45 > > The following line will be executed because `source` is `datasets`. > > https://github.com/langgenius/dify/blob/d7b4d0756e8a538c582ee4d5a57f0830ec305c93/api/services/file_service.py#L45-L46 > > > This will cause anything other than the document file to be rejected. > These changes are from #9906.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6566