Archive for the 'Scala' Category

How to add support for posting multipart forms to the Play Scala WS library

For Process Street‘s Yammer integration, I needed to post file attachments to their API using the Play Scala WS library.

However, it turns out that WS does not yet support uploading files using multipart/form-data and POST. There are several workarounds on the ‘net, but they all involve getting the underlying Ning Java client and doing thing manually.

Why not harness the power of Play and Scala and write our own Writeable to do that job? Heck, we already have a MultipartFormData object for handling multipart form requests, why not use that?

Read more »

Forcing HTTPS in a Play 2 Scala app

At Process Street we’ve been developing a new app called MailTheme that, like the Process Street app, it uses the Play Framework.

Unlike Process Street, MailTheme will be running on Google Cloud and, for the time being, won’t be behind a load balancer or proxy. As such, I needed to make all HTTP requests auto-redirect to HTTPS via Play. This turned out to be more difficult than I first imagined, as Play prior to version 2.3 has no way to detect whether or not the incoming request is over SSL.

Read more »

Play 2 Framework not finding environment variables in IntelliJ IDEA on Mac

Recently I was experiencing an issue with the Play 2 Framework where it could not find environment variables on Mac OS when compiled within IntelliJ IDEA. The solution turned out to be simple, but could be inconvenient when an environment variable is used in many programs.

Read more »