From 8459bebceb9533948193774371cbd9fd571b78ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 16 Oct 2019 09:48:31 +0200 Subject: Cowboy 2.7.0 --- docs/en/cowboy/2.6/guide/multipart/index.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'docs/en/cowboy/2.6/guide/multipart') diff --git a/docs/en/cowboy/2.6/guide/multipart/index.html b/docs/en/cowboy/2.6/guide/multipart/index.html index 191d5d61..14320e48 100644 --- a/docs/en/cowboy/2.6/guide/multipart/index.html +++ b/docs/en/cowboy/2.6/guide/multipart/index.html @@ -73,7 +73,7 @@

The browser does its best to determine the media type of the files it sends this way, but you should not rely on it for determining the contents of the file. Proper investigation of the contents is recommended.

Checking for multipart messages

The content-type header indicates the presence of a multipart message:

-
@@ -85,7 +85,7 @@ http://www.gnu.org/software/src-highlite -->

The cowboy_req:read_part/1,2 functions return the next part's headers, if any.

The cowboy_req:read_part_body/1,2 functions return the current part's body. For large bodies you may need to call the function multiple times.

To read a multipart message you need to iterate over all its parts:

-
@@ -101,7 +101,7 @@ http://www.gnu.org/software/src-highlite -->

When part bodies are too large, Cowboy will return a more tuple, and allow you to loop until the part body has been fully read.

The function cow_multipart:form_data/1 can be used to quickly obtain information about a part from a multipart/form-data message. The function returns a data or a file tuple depending on whether this is a normal field or a file being uploaded.

The following snippet will use this function and use different strategies depending on whether the part is a file:

-
@@ -130,14 +130,14 @@ http://www.gnu.org/software/src-highlite -->

Both the part header and body reading functions can take options that will be given to the request body reading functions. By default, cowboy_req:read_part/1 reads up to 64KB for up to 5 seconds. cowboy_req:read_part_body/1 has the same defaults as cowboy_req:read_body/1.

To change the defaults for part headers:

-
cowboy_req:read_part(Req, #{length => 128000}).

And for part bodies:

-
@@ -146,7 +146,7 @@ http://www.gnu.org/software/src-highlite -->

Skipping unwanted parts

Part bodies do not have to be read. Cowboy will automatically skip it when you request the next part's body.

The following snippet reads all part headers and skips all bodies:

-
@@ -219,6 +219,8 @@ http://www.gnu.org/software/src-highlite --> +
  • 2.7
  • +
  • 2.6
  • 2.5
  • -- cgit v1.2.3