Privimage is a self-hosted image storage solution built using Node.js and MongoDB. It allows you to securely store and retrieve images in a base64 compressed format, making them easy to access and transmit. This README provides an overview of the installation process and basic usage instructions.
- Securely store images on your own server.
- Images are stored in a base64 compressed format for efficient storage and transmission.
- Easy-to-use API for uploading, retrieving, and deleting images.
- Utilizes MongoDB for efficient image management and retrieval.
-
Clone the Repository:
git clone https://github.com/yourusername/privimage.git cd privimage
-
Install Dependencies:
npm install
-
Configure MongoDB:
Update the
config.js
file with your MongoDB connection settings.MongoDB Configuration
-
Create a MongoDB Atlas account or log in to your existing account.
-
Create a new cluster or select an existing cluster.
-
In your cluster's dashboard, click on "Connect" to get your connection string.
Replace , , and <cluster_name> in the following connection string with your MongoDB Atlas credentials and cluster name:
MONGO=mongodb+srv://<username>:<password>@<cluster_name>.mongodb.net/?retryWrites=true&w=majority
Copy the updated connection string and paste it into your project's configuration, replacing the existing MONGO value.
Generate a strong and secure secret key for your application. This key will be used for encryption and security purposes.
Replace <your_secret_key> with your generated secret key:
SECRET_KEY=<your_secret_key>
Copy the updated secret key and paste it into your project's configuration, replacing the existing SECRET_KEY value.
After completing the MongoDB and secret key configurations, your configuration file (config.env or similar) should look like this:
MONGO=mongodb+srv://<username>:<password>@<cluster_name>.mongodb.net/?retryWrites=true&w=majority
SECRET_KEY=<your_secret_key>
SECRET_KEY=<your_secret_key>
-
Start the Server:
npm start
The server will start and listen on the specified port (default: 3000).
-
POST /upload
Upload a new image. Provide the image data in the request body.
-
GET /image/:id
Retrieve an image by its ID.
-
DELETE /image/:id
Delete an image by its ID.
curl -X POST -H "Content-Type: application/json" -d '{"imageData": "base64ImageData"}' http://localhost:3000/upload
Replace base64ImageData
with the actual base64-encoded image data.
Open the following URL in your browser or use a tool like curl
:
http://localhost:3000/image/imageId
Replace imageId
with the ID of the image you want to retrieve.
curl -X DELETE http://localhost:3000/image/imageId
Replace imageId
with the ID of the image you want to delete.
- Authentication and Authorization: Implement proper authentication and authorization mechanisms to secure your Privimage instance.
- Secure MongoDB: Ensure that your MongoDB instance is properly secured with authentication and access control.
This project is licensed under the MIT License - see the LICENSE file for details.
- This project was inspired by the need for a simple, self-hosted image storage solution.
- Thanks to the Node.js and MongoDB communities for their amazing tools and resources.
Feel free to contribute to this project by submitting issues or pull requests. If you have any questions or need assistance, please reach out to us!