Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

File upload example for Spring Boot using converters

License

NotificationsYou 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

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is an example project for a file upload in Spring Boot4.0.0. Uploads can be part of any form using DTOs. In this example you can manage profiles with a resume in PDF or DOC format in a Thymeleaf frontend. Implementation details:

  • Separate tableFileContent for storing file content
  • The entityProfile contains a JSON objectFileData with the name and UID of the file
  • TheFileDataService provides utility functions for uploads and downloads
  • TheConverterConfig registers a converter for transforming uploads fromMultipartFile to aFileData object transparently
  • The annotationValidFileType ensures the correct file type

File Upload Example

This project was created usingBootify.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 inapplication.yml or create your ownapplication-local.yml file to override settings for development.

During development it is recommended to use the profilelocal. 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 underlocalhost:8080.

Build

The application can be built using the following command:

mvnw clean package

Start your application with the following command - here with the profileproduction:

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. AddSPRING_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 using converters

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp