Another common use of REST APIs is to transfer files. This seems an easy task at first; however, it gets complicated when files become large. Most times it is not possible to store an entire file inside an HTTP request if the file is large. The HTTP protocol provides a special Content-Type for this purpose, named multipart/form-data. When using this Content-Type, the file gets sent in parts (known as body parts). Akka HTTP provides a functionality to receive these parts and put the file together on the server side. Moreover, it allows you to run some functionality as the parts are reaching the server to speed up processing in case it is required. This is known as the streaming approach.
In this recipe, we will create a REST API that is able to receive text files in both the approaches-regular and streaming. Also, we will create a client that will upload the...