File Upload and Download-Spring Boot

Keerthana Thiagaraj
Analytics Vidhya
Published in
4 min readJun 13, 2020

--

Let us try to achieve file uploading and downloading using Java 8, Hibernate and PostgreSQL

This article helps to perform Upload and Download action of files regardless of file format. REST endpoints that is generated can be consumed in any front-end frameworks like React js, Angular or Vue js and etc..

What are we going to cover ?

  1. Configuring Database properties
  2. Exposing REST endpoints by establishing relationship to our database
  3. Test the API’s in Postman.

Configuring Database properties

First and foremost, create a Spring project by using either Spring Initializer or Spring Tool Suite. Make sure that the folder structure looks like below:

Project Structure

All Right!. First, let us try to configure database properties in application.properties file.

server.port=8090

#Hibernate database config
spring.datasource.url=jdbc:postgresql://localhost:5432/test
spring.datasource.driver-class-name
=org.postgresql.Driver

#Provide the username&password of your database

--

--