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.38k stars 7.64k forks source link

Http executor node not uploading files to another server #10018

Open je4ngomes opened 3 weeks ago

je4ngomes commented 3 weeks ago

Self Checks

Dify version

0.10.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

✔️ Expected Behavior

Be able to access the uploaded file on the server side

❌ Actual Behavior

The http node is not uploading the actual file

dosubot[bot] commented 3 weeks ago

Hey @je4ngomes! I'm here to help you with any bugs, questions, or contributions you have in mind. Let's work together to solve this issue.

I couldn't find a specific solution for the Http Executor node not uploading files in Dify version 0.10.1. However, I can provide some insights into how the Http Executor node handles file uploads and some common configuration issues that might affect this functionality.

The Http Executor node in Dify uses the HTTP protocol to interact with external servers and supports various HTTP methods, including "post" and "put" for file uploads. It uses the "multipart/form-data" content type for file uploads, which is specified in the headers when the body type is "form-data". The files are prepared as a dictionary where each file is represented as a tuple containing the filename, file content, and MIME type. The request is executed using the httpx library, which handles the HTTP communication with the external server [1].

If you're experiencing issues with file uploads, ensure that the following configurations are correctly set:

  1. FILES_URL: This should be set to an externally accessible address so that the server can access the file. The URL must include a signature with a 5-minute expiration to prevent forgery.
  2. STORAGE_TYPE: Ensure that the storage type is correctly set to either local, s3, or azure-blob based on your storage setup.

For example, if you are using local storage, you need to set:

STORAGE_TYPE=local
STORAGE_LOCAL_PATH=/path/to/storage
FILES_URL=http://your-domain.com/path/to/storage

If you are using S3, you need to set:

STORAGE_TYPE=s3
S3_ENDPOINT=your-s3-endpoint
S3_BUCKET_NAME=your-bucket-name
S3_ACCESS_KEY=your-access-key
S3_SECRET_KEY=your-secret-key
FILES_URL=https://your-s3-endpoint/your-bucket-name

Ensure these configurations are correctly set in your environment variables to enable file upload functionalities [2].

To continue talking to Dosu, mention @dosu.

je4ngomes commented 3 weeks ago

The problem is not related to uploading files into dify, but transferring the actual file to another server using the http executor inside a workflow.

Here is a exemple of the request being received on n8n from dify workflow, as you will see no binary file: image image

Now here is what should be an expected behavior (This one is from postman now): image image