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
47.06k stars 6.68k forks source link

To upload file in the http request block in workflow #9004

Open muckthaa-ss opened 2 hours ago

muckthaa-ss commented 2 hours ago

Self Checks

Dify version

0.6.15

Cloud or Self Hosted

Cloud

Steps to reproduce

To upload file in the http request block in workflow

✔️ Expected Behavior

Upload option in http request block image

❌ Actual Behavior

i cant upload any file in the http block

dosubot[bot] commented 2 hours ago

I found some relevant discussions and issues regarding file uploads in the HTTP request block in Dify:

  1. There is an unsolved discussion titled PDF or text files upload which might be related to your issue [1].
  2. Another discussion, Since there is the parameter 'sys.files' in the workflow setting, A PDF file can be uploaded during the chatflow?, also addresses file upload concerns [2].
  3. A closed issue, HTTP request module does not process files through form-data in its body, suggests ensuring that the request is correctly formatted to handle multipart form-data. It provides an example of how to structure a cURL request for uploading a file [3].

To resolve your issue, make sure your HTTP request is formatted to handle multipart form-data. You can refer to the example provided in the closed issue for guidance on structuring your request.

To continue talking to Dosu, mention @dosu.

muckthaa-ss commented 1 hour ago

sample workflow for file upload in http request

dosubot[bot] commented 1 hour ago

To set up a file upload in an HTTP request block within a Dify workflow, you can use the following cURL example as a guide:

curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create_by_file' \
--header 'Authorization: Bearer {api_key}' \
--form 'data="{\"name\":\"Dify\",\"indexing_technique\":\"high_quality\",\"process_rule\":{\"rules\":{\"pre_processing_rules\":[{\"id\":\"remove_extra_spaces\",\"enabled\":true},{\"id\":\"remove_urls_emails\",\"enabled\":true}],\"segmentation\":{\"separator\":\"###\",\"max_tokens\":500}},\"mode\":\"custom\"}}";type=text/plain' \
--form 'file=@"/path/to/file"'

This example demonstrates how to use a multipart/form-data request to upload a file along with additional data parameters. You need to replace '/path/to/file' with the actual path to your file and fill in the placeholders like ${props.apiBaseUrl}, {dataset_id}, and {api_key} with your specific values [1].

To continue talking to Dosu, mention @dosu.