Lets begin with some introduction of Akka-http first.
Akka HTTP is a layer to expose Actors to the web via HTTP and to enable them to consume HTTP services as a client. It is not an HTTP framework, it is an Actor-based toolkit for interacting with web services and clients. This toolkit is structured into several layers:
- akka-http-core: A complete implementation of the HTTP standard, both as client and server.
- akka-http: A convenient and powerful routing DSL for expressing web services.
- akka-http-testkit: A test harness and set of utilities for verifying your web service implementations.
For more information, see here.
Now its time to go into some code.
To use akka-http, we need to add library in our application. So to do the same, add following dependencies in build.sbt file.:
Now we will write a route to which we can send our file upload request :
Here, what we have done is, as route will get file upload request, it will take the file data as multipart and will create a file at our local machine in system’s temp folder.
That’s it. Hope you enjoyed. Happy Blogging. !!!