Midio docs
  • Getting Started
    • Welcome
    • Quick Start Guide
  • Your First Midio App
  • Guides
    • HTTP
      • Making HTTP Requests
      • Uploading Files (multipart/form-data)
      • Responding to HTTP Requests
      • How to reach your own endpoints
      • CORS
      • Server-Sent Events (SSE)
    • Branching
    • Loops
    • Map, filter, reduce
    • Working with Data
    • Expressions
    • Building Agents
      • Streaming Agent API (experimental)
    • Debugging
    • Secrets and Environment variables
    • Convert JSON to data nodes
    • Writing tests
    • Cleaning up your flows
  • Package Manager
  • Integrating with third party services
  • Troubleshooting
  • Tutorials
    • Connecting LLMs to MCP-servers using the MCP-client package
    • Making Your Own MCP Server in Midio
    • A Fast Path to Functional RAG Agents
    • How to build a streaming agent using Server-Sent Events (SSE)
  • Reference
    • The Midio Editor
      • The Node Editor
      • User Traces
      • Traces (execution)
      • Processes
      • Log
      • Services
      • Problems
      • Function Signature
      • Data
      • Settings
    • The Midio Language
      • Nodes and execution
      • Functions and Events
        • Anonymous functions
      • Modules
      • Contexts
      • Data type
      • Local variables
      • Portals
      • Waypoint node
      • Partial function application
  • The Midio Engine
  • Built in Nodes
    • Core (std)
    • HTTP
    • LLM
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Guides
  2. HTTP

Uploading Files (multipart/form-data)

PreviousMaking HTTP RequestsNextResponding to HTTP Requests

Last updated 2 days ago

Was this helpful?

Some APIs require you to upload files, which is usually done using the multipart/form-data content type.

This can be achieved in Midio using Http.Body.Create Form Field File Http.Body.Create Form Field Value and Http.Body.Encode Multipart FormData .

In the example above, we fetch an image as a buffer, which we then convert to a form field file using Create Form Field File. All form fields are sent as inputs to Encode Multipart FormData, which returns two values: a Content-Type header value and the encoded body. We place the header value in an object with the field value Content-Type and use it in the headers input when calling the API that requires a file upload. We use the multipart/form-data output as the body.

It is important to include the header, as it contains information about how the form data is encoded in the body.