Skip to content

File upload example for Spring Boot in its current version - providing a smart integration into DTOs by using converters.

License

Notifications You must be signed in to change notification settings

bootify-io/spring-boot-file-upload-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot File Upload Example

This is an example project for a file upload in Spring Boot 3.5.3. Manage profiles with a resume in PDF or DOC format in a Thymeleaf frontend. Implementation details:

  • Separate table FileContent for storing file content
  • The entity Profile only contains a JSON object FileData with the name and UID of the file
  • The FileDataService provides utility functions for uploads and downloads
  • The ConverterConfig registers a converter for transforming uploads from MultipartFile to a FileData object
  • The annotation ValidFileType ensures the correct file type

File Upload Example

This project was created using Bootify.io. Choose your preferred frontend and preferences, create your own database schema including file fields, and get a working Spring Boot application directly in your browser.

Development

Update your local database connection in application.yml or create your own application-local.yml file to override settings for development.

During development it is recommended to use the profile local. In IntelliJ -Dspring.profiles.active=local can be added in the VM options of the Run Configuration after enabling this property in "Modify options".

After starting the application it is accessible under localhost:8080.

Build

The application can be built using the following command:

mvnw clean package

Start your application with the following command - here with the profile production:

java -Dspring.profiles.active=production -jar ./target/file-upload-0.0.1-SNAPSHOT.jar

If required, a Docker image can be created with the Spring Boot plugin. Add SPRING_PROFILES_ACTIVE=production as environment variable when running the container.

mvnw spring-boot:build-image -Dspring-boot.build-image.imageName=io.bootify/file-upload

Further readings

About

File upload example for Spring Boot in its current version - providing a smart integration into DTOs by using converters.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published