You'll find a new NixMash demo app on GitHub: NixMash Upload Download with Bootique Jersey. It demos the following functions:
- Single File Upload using FormDataBodyPart
- Single File Upload using InputStream
- Multiple File Upload
- File Upload Integration with the Blueimp jQuery File Upload Plugin
- File Download of multiple file types
- 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.
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.
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.
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.
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.