MultipartParser API

size_t formMultipartParser(HttpRequest &request, const char *at, int length)

Body parser for content-type form-data/multipart

Must be added to the web server’s list of body parsers explicitly:

#include <MultipartParser.h>
...
HttpServer server;
...
server.setBodyParser(MIME_FORM_MULTIPART, formMultipartParser);

class HttpMultipartResource : public HttpResource

HttpResource that allows handling of HTTP file upload.

Public Functions

inline HttpMultipartResource(const HttpFilesMapper &mapper, HttpResourceDelegate complete)

Create and configure a HttpResource for handling file upload.

On a normal computer the file uploads are usually using temporary space on the hard disk or in memory to store the incoming data. On an embedded device that is a luxury that we can hardly afford. Therefore we should define a map that specifies explicitly where every form field will be stored. If a field is not specified then its content will be discarded.

Parameters:
  • mapper – callback that provides information where the desired upload fields will be stored.

  • complete – callback that will be called after the request has completed.

virtual int setFileMap(HttpServerConnection &connection, HttpRequest &request, HttpResponse &response)

Callback implementation for HttpResource::onHeadersComplete. Not to be used by application code.

inline virtual void shutdown(HttpServerConnection&) override

Takes care to cleanup the connection.