2023-04-05 19:58:34 +03:00
< pre > < code class = "language-hurl" > < span class = "hurl-entry" > < span class = "request" > < span class = "line" > < / span > < span class = "comment" > # On can use the dedicated [MultipartFormData] section< / span >
< span class = "line" > < span class = "method" > POST< / span > < span class = "url" > http://localhost:8000/multipart-form-data< / span > < / span >
2023-04-11 18:28:28 +03:00
< span class = "line" > < span class = "section-header" > [MultipartFormData]< / span > < / span >
2023-04-17 14:05:34 +03:00
< span class = "line" > < span class = "string" > key1< / span > : < span class = "string" > value1< / span > < / span >
2023-01-11 14:14:32 +03:00
< span class = "line" > < span class = "string" > upload1< / span > : file,< span class = "filename" > data.txt< / span > ;< / span >
< span class = "line" > < span class = "string" > upload2< / span > : file,< span class = "filename" > data.html< / span > ;< / span >
< span class = "line" > < span class = "string" > upload3< / span > : file,< span class = "filename" > data.txt< / span > ; < span class = "string" > text/html< / span > < / span >
2023-04-05 19:58:34 +03:00
< / span > < span class = "response" > < span class = "line" > < span class = "version" > HTTP< / span > < span class = "number" > 200< / span > < / span >
< / span > < / span > < span class = "hurl-entry" > < span class = "request" > < span class = "line" > < / span >
2021-09-21 07:36:53 +03:00
< span class = "line" > < / span >
2023-04-05 19:58:34 +03:00
< span class = "line" > < / span > < span class = "comment" > # Or, as an alternative to the [MultipartFormData] section, we can just use< / span >
< span class = "line" > < / span > < span class = "comment" > # a multiline string body, constructing boundaries by hand (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST).< / span >
< span class = "line" > < / span > < span class = "comment" > # The downside of this method is that we must inline the files content (for the moment).< / span >
< span class = "line" > < span class = "method" > POST< / span > < span class = "url" > http://localhost:8000/multipart-form-data< / span > < / span >
2023-04-17 14:05:34 +03:00
< span class = "line" > < span class = "string" > Content-Type< / span > : < span class = "string" > multipart/form-data; boundary="boundary"< / span > < / span >
2023-04-05 19:58:34 +03:00
< span class = "multiline" > < span class = "line" > ```< / span >
< span class = "line" > --boundary< / span >
< span class = "line" > Content-Disposition: form-data; name="key1"< / span >
2021-09-21 07:36:53 +03:00
< span class = "line" > < / span >
2023-04-05 19:58:34 +03:00
< span class = "line" > value1< / span >
< span class = "line" > --boundary< / span >
< span class = "line" > Content-Disposition: form-data; name="upload1"; filename="data.txt"< / span >
< span class = "line" > Content-Type: text/plain< / span >
< span class = "line" > < / span >
< span class = "line" > Hello World!< / span >
< span class = "line" > --boundary< / span >
< span class = "line" > Content-Disposition: form-data; name="upload2"; filename="data.html"< / span >
< span class = "line" > Content-Type: text/html< / span >
< span class = "line" > < / span >
< span class = "line" > < div> Hello < b> World< /b> !< /div> < / span >
< span class = "line" > --boundary< / span >
< span class = "line" > Content-Disposition: form-data; name="upload3"; filename="data.txt"< / span >
< span class = "line" > Content-Type: text/html< / span >
< span class = "line" > < / span >
< span class = "line" > Hello World!< / span >
< span class = "line" > --boundary--< / span >
< span class = "line" > ```< / span > < / span >
< / span > < span class = "response" > < span class = "line" > < span class = "version" > HTTP< / span > < span class = "number" > 200< / span > < / span >
< / span > < / span > < / code > < / pre >