Anonymous committed 79def84

add find_boundary/1 courtesy of Andy Gross

Comments (0)

Files changed (1)


 %% @author Justin Sheehy <>
+%% @author Andy Gross <>
 %% @copyright 2009 Basho Technologies
 %% @doc Utility for parsing multipart form bodies.
 -author('Justin Sheehy <>').
+-author('Andy Gross <>').
+-export([get_all_parts/2,stream_parts/2, find_boundary/1]).
 % @type incoming_req_body() = binary().
 % @type fcontent() = binary().
 % The body content within a form part.
+% @doc Find the multipart boundary for a request.
+% @spec find_boundary(wrq:wm_reqdata()) -> boundary()
+find_boundary(ReqData) ->
+    ContentType = wrq:get_req_header("content-type", ReqData),
+    string:substr(ContentType, string:str(ContentType, "boundary=") 
+                  + length("boundary=")).
 % @doc Turn a multipart form into component parts.
 % @spec get_all_parts(incoming_req_body(), boundary()) -> [fpart()]
 get_all_parts(Body, Boundary) when is_binary(Body), is_list(Boundary) ->
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.