Tutorial : File Upload & Download with SpringBoot and MongoDB
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
- 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
That's all! Good Luck 💪