hansitharaka / springboot-mongodb-file-upload-download

File upload/download with Spring Boot and MongoDB GridFS

Home Page:https://hansanitharaka.medium.com/file-upload-with-springboot-and-mongodb-76a8f5b9f75d

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 💪

About

File upload/download with Spring Boot and MongoDB GridFS

https://hansanitharaka.medium.com/file-upload-with-springboot-and-mongodb-76a8f5b9f75d


Languages

Language:Java 64.0%Language:CSS 14.5%Language:HTML 10.9%Language:JavaScript 10.5%