Skip to content

hansitharaka/springboot-mongodb-file-upload-download

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Upload / Download Example using Spring Boot and MongoDB

Tutorial : File Upload & Download with SpringBoot and MongoDB

Getting Started

1. Clone the repository

git clone https://github.com/hansitharaka/springboot-mongodb-file-upload-download.git

2. Specify your database

Open src/main/resources/application.properties file and change following properties accordingly.

spring.data.mongodb.port = [db port]
spring.data.mongodb.host = [host]
spring.data.mongodb.database = [database name]

if you are using MongoDB Atlas, use the following configuration.

  • Replace with admin password and with your database name.
spring.data.mongodb.uri=mongodb+srv://admin:<password>@cluster0.eypdh.mongodb.net/<database>?retryWrites=true&w=majority

REST end-points

  • Upload a File: http://localhost:8080/file/upload
  • Download a File: http://localhost:8080/file/download/{id}

The application can be accessed at http://localhost:8080 or open src/main/resources/static/index.html to access frontend

File upload frontend snapshot

That's all! Good Luck 💪