{"action":"opened","issue":{"url":"https://api.github.com/repos/vert-x3/vertx-web/issues/351","repository_url":"https://api.github.com/repos/vert-x3/vertx-web","labels_url":"https://api.github.com/repos/vert-x3/vertx-web/issues/351/labels{/name}","comments_url":"https://api.github.com/repos/vert-x3/vertx-web/issues/351/comments","events_url":"https://api.github.com/repos/vert-x3/vertx-web/issues/351/events","html_url":"https://github.com/vert-x3/vertx-web/issues/351","id":145226621,"number":351,"title":"BodyHandler saves multipart/form-data body into files and memory","user":{"login":"berserkk","id":3935276,"avatar_url":"https://avatars.githubusercontent.com/u/3935276?v=3","gravatar_id":"","url":"https://api.github.com/users/berserkk","html_url":"https://github.com/berserkk","followers_url":"https://api.github.com/users/berserkk/followers","following_url":"https://api.github.com/users/berserkk/following{/other_user}","gists_url":"https://api.github.com/users/berserkk/gists{/gist_id}","starred_url":"https://api.github.com/users/berserkk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berserkk/subscriptions","organizations_url":"https://api.github.com/users/berserkk/orgs","repos_url":"https://api.github.com/users/berserkk/repos","events_url":"https://api.github.com/users/berserkk/events{/privacy}","received_events_url":"https://api.github.com/users/berserkk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-01T16:39:04Z","updated_at":"2016-04-01T16:39:04Z","closed_at":null,"body":"Browser uses `Content-Type: multipart/form-data` for uploading files. `BodyHandler` saves files from request body to local files, but also collects request body into memory. This means, that large file uploads (100 MB, 1 Gb...), especially if they're slow, can use very big part of server memory or even cause `OutOfMemoryError` exception.\r\n\r\nSmall reproducer.\r\n\r\n1) Create routes:\r\n```java\r\nrouter.route().handler(BodyHandler.create());\r\n\r\nrouter.post(\"/upload\").handler(context -> {\r\n    context.response().headers().set(\"Content-Type\", \"text/plain\");\r\n    context.response().end(context.getBody()); // returns request body (uploaded files, fields, metadata)\r\n});\r\n```\r\n\r\n2) Create `html` page to upload file:\r\n```html\r\n<form method=\"POST\" action=\"http://localhost:8080/upload\" enctype=\"multipart/form-data\">\r\n    <input type=\"file\" name=\"file\" />\r\n    <input type=\"hidden\" name=\"field\" value=\"value\" />\r\n    <input type=\"submit\" value=\"Upload\" />\r\n</form>\r\n```"}}