chat-messages API for file upload #6517

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

Originally created by @JiesenSun on GitHub (Nov 3, 2024).

Originally assigned to: @crazywoola 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.10.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Test the chat-messages api according to the documentation, and invalid_param error always exists. Please see the attached picture.
image
b

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @JiesenSun on GitHub (Nov 3, 2024). Originally assigned to: @crazywoola 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.10.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Test the chat-messages api according to the documentation, and invalid_param error always exists. Please see the attached picture. <img width="1358" alt="image" src="https://github.com/user-attachments/assets/b56ff141-fcc7-4c4f-bd3d-da7e14a4f6f1"> ![b](https://github.com/user-attachments/assets/8053febb-b1e6-4f54-acae-84db580ecb62) ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:16:06 -05:00
yindo closed this issue 2026-02-21 18:16:06 -05:00
Author
Owner

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

Hey @JiesenSun! 👋 I'm here to help you with bugs, questions, and becoming a contributor. If you need assistance, feel free to ask!

I found a similar issue regarding the "invalid_param" error when using the chat-messages API for file uploads in Dify version 0.10.2 on a self-hosted Docker setup. To resolve this issue, ensure that you are correctly using the transfer_method and providing the necessary parameters based on the method chosen.

For file uploads, use the local_file transfer method and provide the upload_file_id obtained from the File Upload API. Here’s a brief guide:

  1. Upload the File: Use the File Upload API with a multipart/form-data request, including the file and a unique user identifier.

    Example cURL command:

    curl -X POST '${props.appDetail.api_base_url}/files/upload' \
    --header 'Authorization: Bearer {api_key}' \
    --form 'file=@"/path/to/file"' \
    --form 'user=abc-123'
    
  2. Use the File ID: After uploading, the server returns a file ID. Use this ID in your chat-messages API request.

  3. Make the Chat-Messages API Request: Use the local_file transfer method and include the upload_file_id.

    Example JSON payload:

    {
        "inputs": {},
        "query": "What are the specs of the iPhone 13 Pro Max?",
        "response_mode": "streaming",
        "conversation_id": "",
        "user": "abc-123",
        "files": [
            {
                "type": "image",
                "transfer_method": "local_file",
                "upload_file_id": "72fa9618-8f89-4a37-9b33-7e1178a24a67"
            }
        ]
    }
    

Ensure all parameters are correctly set and the file ID is valid. Verify that the response_mode is set correctly as either blocking or streaming [1][2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Nov 3, 2024): <!-- Greeting --> Hey @JiesenSun! 👋 I'm here to help you with bugs, questions, and becoming a contributor. If you need assistance, feel free to ask! <!-- Answer --> I found a similar issue regarding the "invalid_param" error when using the chat-messages API for file uploads in Dify version 0.10.2 on a self-hosted Docker setup. To resolve this issue, ensure that you are correctly using the `transfer_method` and providing the necessary parameters based on the method chosen. For file uploads, use the `local_file` transfer method and provide the `upload_file_id` obtained from the File Upload API. Here’s a brief guide: 1. **Upload the File**: Use the File Upload API with a `multipart/form-data` request, including the file and a unique user identifier. Example cURL command: ```bash curl -X POST '${props.appDetail.api_base_url}/files/upload' \ --header 'Authorization: Bearer {api_key}' \ --form 'file=@"/path/to/file"' \ --form 'user=abc-123' ``` 2. **Use the File ID**: After uploading, the server returns a file ID. Use this ID in your chat-messages API request. 3. **Make the Chat-Messages API Request**: Use the `local_file` transfer method and include the `upload_file_id`. Example JSON payload: ```json { "inputs": {}, "query": "What are the specs of the iPhone 13 Pro Max?", "response_mode": "streaming", "conversation_id": "", "user": "abc-123", "files": [ { "type": "image", "transfer_method": "local_file", "upload_file_id": "72fa9618-8f89-4a37-9b33-7e1178a24a67" } ] } ``` Ensure all parameters are correctly set and the file ID is valid. Verify that the `response_mode` is set correctly as either `blocking` or `streaming` <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_chat.en.mdx)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_advanced_chat.en.mdx)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@MitraSafarinejad commented on GitHub (Nov 3, 2024):

I am experiencing a similar issue after updating to version 0.10.2. When I attempt to upload an image, I consistently receive the following error message:

{
  "code": "unsupported_file_type",
  "message": "File type not allowed.",
  "status": 415
}

This error occurs regardless of the image file type I try to upload. I have verified that the images I am attempting to upload are in a supported format (such as .jpg and .png). Despite this, the API rejects my uploads with the unsupported file type error.

Here's my curl command:

curl --location '.../v1/files/upload' \
--header 'Authorization: Bearer ' \
--form 'file=@"/home/Pictures/images.jpeg"'
@MitraSafarinejad commented on GitHub (Nov 3, 2024): I am experiencing a similar issue after updating to version 0.10.2. When I attempt to upload an image, I consistently receive the following error message: ``` { "code": "unsupported_file_type", "message": "File type not allowed.", "status": 415 } ``` This error occurs regardless of the image file type I try to upload. I have verified that the images I am attempting to upload are in a supported format (such as .jpg and .png). Despite this, the API rejects my uploads with the unsupported file type error. Here's my curl command: ``` curl --location '.../v1/files/upload' \ --header 'Authorization: Bearer ' \ --form 'file=@"/home/Pictures/images.jpeg"' ```
Author
Owner

@JiesenSun commented on GitHub (Nov 3, 2024):

Hey @JiesenSun! 👋 I'm here to help you with bugs, questions, and becoming a contributor. If you need assistance, feel free to ask!

I found a similar issue regarding the "invalid_param" error when using the chat-messages API for file uploads in Dify version 0.10.2 on a self-hosted Docker setup. To resolve this issue, ensure that you are correctly using the transfer_method and providing the necessary parameters based on the method chosen.

For file uploads, use the local_file transfer method and provide the upload_file_id obtained from the File Upload API. Here’s a brief guide:

  1. Upload the File: Use the File Upload API with a multipart/form-data request, including the file and a unique user identifier.
    Example cURL command:
    curl -X POST '${props.appDetail.api_base_url}/files/upload' \
    --header 'Authorization: Bearer {api_key}' \
    --form 'file=@"/path/to/file"' \
    --form 'user=abc-123'
    
  2. Use the File ID: After uploading, the server returns a file ID. Use this ID in your chat-messages API request.
  3. Make the Chat-Messages API Request: Use the local_file transfer method and include the upload_file_id.
    Example JSON payload:
    {
        "inputs": {},
        "query": "What are the specs of the iPhone 13 Pro Max?",
        "response_mode": "streaming",
        "conversation_id": "",
        "user": "abc-123",
        "files": [
            {
                "type": "image",
                "transfer_method": "local_file",
                "upload_file_id": "72fa9618-8f89-4a37-9b33-7e1178a24a67"
            }
        ]
    }
    

Ensure all parameters are correctly set and the file ID is valid. Verify that the response_mode is set correctly as either blocking or streaming [1][2].

To continue talking to Dosu, mention @dosu.

The second method in the attached picture in the original text uses the same method as yours, but still reports an error. My scenario here is a document dialogue, not a picture dialogue.
image

@JiesenSun commented on GitHub (Nov 3, 2024): > Hey @JiesenSun! 👋 I'm here to help you with bugs, questions, and becoming a contributor. If you need assistance, feel free to ask! > > I found a similar issue regarding the "invalid_param" error when using the chat-messages API for file uploads in Dify version 0.10.2 on a self-hosted Docker setup. To resolve this issue, ensure that you are correctly using the `transfer_method` and providing the necessary parameters based on the method chosen. > > For file uploads, use the `local_file` transfer method and provide the `upload_file_id` obtained from the File Upload API. Here’s a brief guide: > > 1. **Upload the File**: Use the File Upload API with a `multipart/form-data` request, including the file and a unique user identifier. > Example cURL command: > ```shell > curl -X POST '${props.appDetail.api_base_url}/files/upload' \ > --header 'Authorization: Bearer {api_key}' \ > --form 'file=@"/path/to/file"' \ > --form 'user=abc-123' > ``` > 2. **Use the File ID**: After uploading, the server returns a file ID. Use this ID in your chat-messages API request. > 3. **Make the Chat-Messages API Request**: Use the `local_file` transfer method and include the `upload_file_id`. > Example JSON payload: > ```json > { > "inputs": {}, > "query": "What are the specs of the iPhone 13 Pro Max?", > "response_mode": "streaming", > "conversation_id": "", > "user": "abc-123", > "files": [ > { > "type": "image", > "transfer_method": "local_file", > "upload_file_id": "72fa9618-8f89-4a37-9b33-7e1178a24a67" > } > ] > } > ``` > > Ensure all parameters are correctly set and the file ID is valid. Verify that the `response_mode` is set correctly as either `blocking` or `streaming` [[1]](https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_chat.en.mdx)[[2]](https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_advanced_chat.en.mdx). > > _To continue talking to [Dosu](https://dosu.dev), mention @dosu._ The second method in the attached picture in the original text uses the same method as yours, but still reports an error. My scenario here is a document dialogue, not a picture dialogue. <img width="689" alt="image" src="https://github.com/user-attachments/assets/ec0214d4-94c7-4fd5-bc44-7b4aa5b2b799">
Author
Owner

@Allamss commented on GitHub (Nov 7, 2024):

I am experiencing a similar issue after updating to version 0.10.2. When I attempt to upload an image, I consistently receive the following error message:

{
  "code": "unsupported_file_type",
  "message": "File type not allowed.",
  "status": 415
}

This error occurs regardless of the image file type I try to upload. I have verified that the images I am attempting to upload are in a supported format (such as .jpg and .png). Despite this, the API rejects my uploads with the unsupported file type error.

Here's my curl command:

curl --location '.../v1/files/upload' \
--header 'Authorization: Bearer ' \
--form 'file=@"/home/Pictures/images.jpeg"'

@dosu

@Allamss commented on GitHub (Nov 7, 2024): > I am experiencing a similar issue after updating to version 0.10.2. When I attempt to upload an image, I consistently receive the following error message: > > ``` > { > "code": "unsupported_file_type", > "message": "File type not allowed.", > "status": 415 > } > ``` > > This error occurs regardless of the image file type I try to upload. I have verified that the images I am attempting to upload are in a supported format (such as .jpg and .png). Despite this, the API rejects my uploads with the unsupported file type error. > > Here's my curl command: > > ``` > curl --location '.../v1/files/upload' \ > --header 'Authorization: Bearer ' \ > --form 'file=@"/home/Pictures/images.jpeg"' > ``` @dosu
Author
Owner

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

The error message "unsupported_file_type" suggests that the file type you're trying to upload is not recognized as supported by the API, even though formats like .jpg and .png are indeed supported in Dify version 0.10.2 [1].

Here are a few things to check and try:

  1. File Extension and MIME Type: Ensure that the file extension and MIME type are correctly recognized. Sometimes, files might have the correct extension but an incorrect MIME type, which can cause issues.

  2. File Validation Logic: The file validation logic checks both the file extension and size. Make sure the file size is within the allowed limit (15MB per file) [1].

  3. API Key and Authorization: Double-check that your API key is correctly included in the Authorization header. An incorrect or missing API key can lead to unexpected errors.

  4. Server Configuration: Ensure that your server configuration allows the file types you are trying to upload. There might be a configuration issue on the server side that restricts certain file types.

  5. Update and Restart: If you recently updated to version 0.10.2, ensure that all services are properly restarted to apply the new configurations.

If these steps do not resolve the issue, consider checking the server logs for more detailed error messages that might provide additional insights into the problem.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Nov 7, 2024): <!-- Answer --> The error message "unsupported_file_type" suggests that the file type you're trying to upload is not recognized as supported by the API, even though formats like `.jpg` and `.png` are indeed supported in Dify version 0.10.2 <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/guides/workflow/file-upload.md)</sup>. Here are a few things to check and try: 1. **File Extension and MIME Type**: Ensure that the file extension and MIME type are correctly recognized. Sometimes, files might have the correct extension but an incorrect MIME type, which can cause issues. 2. **File Validation Logic**: The file validation logic checks both the file extension and size. Make sure the file size is within the allowed limit (15MB per file) <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/guides/workflow/file-upload.md)</sup>. 3. **API Key and Authorization**: Double-check that your API key is correctly included in the `Authorization` header. An incorrect or missing API key can lead to unexpected errors. 4. **Server Configuration**: Ensure that your server configuration allows the file types you are trying to upload. There might be a configuration issue on the server side that restricts certain file types. 5. **Update and Restart**: If you recently updated to version 0.10.2, ensure that all services are properly restarted to apply the new configurations. If these steps do not resolve the issue, consider checking the server logs for more detailed error messages that might provide additional insights into the problem. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

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

Related https://github.com/langgenius/dify/issues/10327
Should be fixed in https://github.com/langgenius/dify/pull/10353

@crazywoola commented on GitHub (Nov 7, 2024): Related https://github.com/langgenius/dify/issues/10327 Should be fixed in https://github.com/langgenius/dify/pull/10353
Author
Owner

@simonlee2 commented on GitHub (Nov 8, 2024):

@crazywoola thanks for the fix. is there an eta for the next release?

@simonlee2 commented on GitHub (Nov 8, 2024): @crazywoola thanks for the fix. is there an eta for the next release?
Author
Owner

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

Maybe in next week @simonlee2

@crazywoola commented on GitHub (Nov 8, 2024): Maybe in next week @simonlee2
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6517