This Node.js and Express.js backend project provides a versatile API for uploading images and videos. The backend application also sends an auto-generated email notification to the user after successful uploading of media. MongoDB Atlas is used as the database, and Postman can be utilized to test the API routes.
-
Local File Upload:
- Route:
http://localhost:4000/api/v1/upload/localFileUpload
- Uploads or moves a file to the chosen directory of the developer. Allows files of any extension.
- Route:
-
Image Upload:
- Route:
http://localhost:4000/api/v1/upload/imageUpload
- Uploads an image file to the database and the developer's Cloudinary account and chosen folder. Allows files of jpg, jpeg, and png extensions only.
- Route:
-
Video Upload:
- Route:
http://localhost:4000/api/v1/upload/videoUpload
- Uploads a video file to the database and the developer's Cloudinary account and chosen folder. Allows files of mp4 and mov extensions only.
- Route:
-
Image Size Reducer:
- Route:
http://localhost:4000/api/v1/upload/imageSizeReducer
- Compresses the size of an image and then uploads the image file to the database and the developer's Cloudinary account and chosen folder. Allows files of jpg, jpeg, and png extensions only.
- Route:
- node.js
- express.js
- nodemailer
- cloudinary api
- mongodb compass
- postman
- Email Notification:
- Upon successful saving of the user's entry into the database, a post-middleware sends an email to the user's provided email address using Nodemailer.
Ensure to set the following environment variables for proper functionality:
MONGODB_URL
: MongoDB Atlas link.CLOUD_NAME
,API_KEY
,API_SECRET
: Cloudinary account information.MAIL_USER
,MAIL_PASS
: Mailing user ID and auto-generated password for Nodemailer.
-
Clone the repository
-
Install dependencies:
npm install
-
Set environment variables in a .env file.
-
Start the server:
npm run dev
Use Postman or any API testing tool to interact with the following routes:
- Local File Upload:
POST http://localhost:4000/api/v1/upload/localFileUpload
- Image Upload:
POST http://localhost:4000/api/v1/upload/imageUpload
- Video Upload:
POST http://localhost:4000/api/v1/upload/videoUpload
- Image Size Reducer and Uploader:
POST http://localhost:4000/api/v1/upload/imageSizeReducer
Thank you for considering contributing to the Media Upload Backend! Contributions help improve the project and make it better for everyone.
To contribute, follow these steps:
-
Fork the repository.
-
Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature
or
git checkout -b bugfix/your-bugfix
-
Make your changes, commit them, and push to your fork:
git add . git commit -m 'Your descriptive commit message' git push origin feature/your-feature
-
Open a Pull Request (PR) on the original repository.
- Provide a detailed description of your changes in the PR.
- Reference any relevant issues or related PRs.
-
Your PR will be reviewed, and once approved, it will be merged into the main branch.
This project is licensed under the MIT License.