Sponsored Advertisement

File Upload Download with Jersey Demo App

You'll find a new NixMash demo app on GitHub: NixMash Upload Download with Bootique Jersey. It demos the following functions:

  1. Single File Upload using FormDataBodyPart
  2. Single File Upload using InputStream
  3. Multiple File Upload
  4. File Upload Integration with the Blueimp jQuery File Upload Plugin
  5. File Download of multiple file types
  6. Secure File Download by User Role

We'll dig into the various functions in separate blog posts. Today we'll walk through the screenshots so you'll know what is available.

Home Page

The Home Page lists the functions to date, those listed in the above list.

Single File Uploads

Here we're uploading a single file, with the option of using a @FormDataParam InputStream or a FormDataBodyPart approach. We're using the Bootstrap FileStyle enhancement to get the good looking Input controls.

MultiFile Uploads

Here we're extending the Single File Uploads with the ability to upload multiple files using List<FormDataBodyPart> on the server and some good old fashioned Javascript on the client.

Jersey Integration with Blueimp

This is probably the biggest draw of the demo app, using the Blueimp jQuery File Upload Plugin with Jersey on the backside. I integrated Blueimp with Spring Boot which I wrote about here, and wanted to do the same in the cleaner environment of Bootique Jersey.

File Downloads

Here are the File Downloads options. We're demonstrating public downloads as well as two different security levels of file access based on User Role: user and admin.

User Authentication

To secure files we need user authentication so there is Apache Shiro to handle that for us, with the two supported demo accounts.

When the user logs in they are directed back to the File Downloads menu with an Alert displaying their file access.

Handling Unauthorized File Access

When a user without admin file access tries to download an admin file they are redirected to the Unauthorized page.

As I said, we'll get into the particulars in future posts. In those posts you'll see links back to this post for reference.

Source Code Notes for this Post

Source code discussed in this post is found in my File Upload and Download in Bootique Jersey app on GitHub.

More Like This Post