Chapter 6. Handling files

This chapter covers

  • Serving files to a client via HTTP
  • Receiving files from a client as an HTTP file upload

This chapter discusses how to implement file exchange over HTTP with Scalatra. As an example, you’ll build a basic document store application that acts as an HTTP-based file server. It will serve documents from the filesystem, and new documents can be uploaded by a client. The user interface is depicted in figure 6.1.

Figure 6.1. User interface for the document store example

6.1. Serving files

First we’ll discuss how to serve non-HTML files, such as text documents, web assets, and media files from a route. ...

Get Scalatra in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.