Uploadify is a Node.js application that provides API endpoints for uploading, retrieving, and managing images.
Uploadify allows users to upload images, retrieve details of a single image, and view details of all uploaded images.
- config/
- config.ts
- database/
- db.ts
- middlewares/
- multerConfig.ts
- models/
- uploadModel.ts
- routes/
- uploadRoutes.ts
- controllers/
- uploadController.ts
- index.ts
- .env
- Clone or download this repository to your local machine.
git clone https://github.com/kobiowuquadri/Uploadify.git
cd uploadify
- Install dependencies:
npm install
- Create a .env file: Create a .env file in the root of your project with the following content:
MONGODB_USERNAME=your-mongodb-username
MONGODB_PASSWORD=your-mongodb-password
PORT= your-port
- Start the server:
nodemon
Endpoint-> POST: /upload
Success: 201 Created
{
"success": true,
"message": "Image Uploaded Successfully",
"savedImage": {
"path": "uploads/image-1705622101980.jpg",
"_id": "65a9ba56e77a61439e29a142",
"createdAt": "2024-01-18T23:55:02.032Z",
"updatedAt": "2024-01-18T23:55:02.032Z",
"__v": 0
}
}
Failure: 400 Bad Request, 500 Internal Server Error
replace: imageId with the image id
Success: 200 Ok
{
"success": true,
"message": "Request Successfully",
"image": {
"_id": "65a9ba56e77a61439e29a142",
"path": "uploads/image-1705622101980.jpg",
"createdAt": "2024-01-18T23:55:02.032Z",
"updatedAt": "2024-01-18T23:55:02.032Z",
"__v": 0
}
}
Failure: 404 Not Found, 500 Internal Server Error
Success: 200 Ok
{
"success": true,
"message": "View all images successfully",
"images": [
{
"_id": "65a9ba56e77a61439e29a142",
"path": "uploads/image-1705622101980.jpg",
"createdAt": "2024-01-18T23:55:02.032Z",
"updatedAt": "2024-01-18T23:55:02.032Z",
"__v": 0
}
]
}
Use the following examples or code snippets to interact with the API:
curl -X POST -F "image=@path/to/your-image.jpg" http://localhost:5000/upload
curl http://localhost:5000/get_image/unique-image-id
curl http://localhost:5000/get_images
To view static images on the web, use the following pattern:
http://localhost:5000/uploads/your-image-filename.png
Replace "your-image-filename.png" with the actual filename of the image you want to view. This URL follows the structure of the static file path and allows you to access the image directly through a web browser.
This project is licensed under the MIT License.