vapor-docs/3.0/docs/http/multipart.md

690 B

Multipart Forms

Multipart is a module that is primarily used with Forms. Multipart is used for complex forms containing one or more files, input fields and other HTML form data.

Parsing a multipart form

Multipart forms can be parsed using MultipartParser.

let multipartForm = try MultipartParser.parse(from: request)

Reading forms

The parsed form is an array of Part instances. Each of them contains data and headers.

You can read a part using either manually or using the Form's helpers.

let pictureData = try multipartForm.getFile(forName: "profile-picture")
let newPassword = try multipartForm.getString(forName: "password")