Tus java server demo using Spring Boot that uses the tus-java-server library and the Uppy file uploader in order to easily provide asynchronous and resumable file uploads in Spring.
To build and run this demo, execute the following commands:
$ git clone https://github.com/tomdesair/tus-java-server-spring-demo.git
$ cd tus-java-server-spring-demo
$ mvn clean package
$ java -jar spring-boot-rest/target/spring-boot-rest-0.0.1-SNAPSHOT.jar
Then visit http://localhost:8080/test/ in your browser and try to upload a file using the Uppy file uploader.
-
Module
spring-boot-rest
provides the API backend for receiving tus file uploads:- Method
me.desair.spring.tus.App#tusFileUploadService
create aTusFileUploadService
Spring bean based on the Spring Boot configuration that can be auto-wired into other beans. - The
me.desair.spring.tus.FileUploadController
provides the/api/upload
endpoint and passes all request directly to thatTusFileUploadService
bean. - Class
me.desair.spring.tus.client.UploadScript
is a script to upload a file using thetus-java-client
library and can be ignored. - File
src/main/resources/public/index.html
contains the actual home page and loads the Uppy JavaScript file generated by theuppy-file-upload
module.
- Method
-
Module
uppy-file-upload
contains the Webpack and Uppy configuration to fetch and join all required JavaScript files. This is not a production ready setup!- File
uppy-file-upload/app/uppy-fileupload.js
contains the configuration parameters of the Uppy tus JS client.
- File