playframework / playframework/playframework

Create a BodyParser to parse MultipartFormData directly to a stream

Open
#9,852 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
Scala
Stars
12.6k
Forks
4k
Avg merge
2d 3h
Merged PRs (30d)
29

Description

Play Version

2.7

API

Scala (Ideally, both)

Feature Description

As of now, the documentation only details how to use parse.multipartFormData and parse.temporaryFile. Both approaches store temporary files, which is not ideal in a Dockerized deployment. The alternative that is suggested is to create your own BodyParser to handle the bytes as they stream in.

I propose that a multipartFormData parser should be created, which provides the body as an Akka Stream (of type Source[ByteString, Any]. This will allow you to skip storing temporary files, and gives you an idiomatic and recommended way to handle the bytes by passing it to the next destination. This is especially helpful for use cases where you are using Play as a simple frontend or gateway, and just want to pass the bytes anyway.

Providing a streamed approach encourages developers to evaluate streaming as a solution for handling files. Right now, the recommendation to build your own BodyParser deters new developers from considering anything outside of temporary file storage.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading Play 2.7's parse.multipartFormData and parse.temporaryFile documentation and the custom BodyParser guidance. Investigate how a parser could expose an Akka Stream Source[ByteString, Any] for multipart data. Done means a supported Scala, ideally both-API, approach streams bytes without temporary-file storage.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.