algesten / ureq

A simple, safe HTTP client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Multipart Forms

FallenValkyrie opened this issue · comments

Currently I cannot find any support for sending multipart Form data (multipart/form-data), It would be great If that was possible.

It's quite easy to do youself, just:

  1. generate a random boundary
  2. Set HTTP content type header with said boundary like this "multipart/form-data; boundary={}"
  3. For each part, loop this to create the HTTP body
    • write start delimiter --BOUNDARY
    • write "Content-Disposition" header and other optional HTTP headers for this specific part
    • write \r\n\r\n to end header section
    • write part body
    • write \r\n
  4. Write ending boundary --BOUNDARY--

I have done this, but it is unfortunately not open source and has multiple very specific details that only fits my rare use-case so it's not really suitable for upstreaming.