Use Spring Data REST to upload, store, and manage pictures
Java JavaScript CSS HTML Other
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Build Status

This snapshot copy is captured from SpringOne 2GX 2015 in Washingon, D.C.

Spring-a-Gram is a demonstration of the Spring stack used to upload and view pictures.

Spring Data REST makes it incredibly simple to define and export data store entities. What does this mean? You declare the POJOs that are stored in your database. In this case, we are using a JPA, in-memory data store. (Spring Data REST supports other data stores as well). You then define a related repository interface. Spring Data REST takes it from there to create a hypermedia-driven, RESTful interface using Spring MVC that lets you create, read, update, and delete data.

This sample application demonstrations how declaring a backend aimed at storing image data can make it as simple as possible to upload pictures and then turn around and display them on a website. This opens the door to other front ends, like an iOS or Android app.

If you want to run it right now, you need:

To download and run:

  1. git clone to grab a local copy (or clone your own fork).

  2. bower install to pull down javascript libraries. If you get prompted about jQuery, accept the version specified in bower.json

  3. mvn clean spring-boot:run

To deploy a copy to PWS, you need a Java 8 build pack. Execute cf push spring-a-gram -p target/spring-a-gram-0.1.0.jar -b and you’ll be set.

This should get the app started courtesy of Spring Boot. Now you can traverse the app from different view points.

  • From the command line, interrogate the API with curl localhost:8080/api. Navigate to the other links.

  • From the desktop, visit http://localhost:8080 to see the Desktop version of the web experience.

  • From a mobile device, visit http://localhost:8080 and see a different flow, optimized for the smaller real estate.