This project is a Node.js application designed to function as a personal cloud storage or simple drive clone. It allows users to upload, store, and manage files securely, with features like user authentication and file organization.
- File Upload and Storage: Easily upload and store various file types.
- User Authentication: Secure user login and session management using Google OAuth2.0.
- File Management: View, download, and delete your uploaded files.
- Directory Browsing: Navigate through your stored files and folders.
- Multi-file Move: Move multiple files or folders simultaneously.
- File Preview: Preview images and videos directly in the browser.
- Appropriate File Icons: Display specific icons for different file types (e.g., images, videos, folders).
- Admin Panel: (If applicable) Manage users and system settings.
- Error Handling: Custom error pages for forbidden access and pending states.
To get a local copy up and running, follow these simple steps.
- Node.js and npm (if running without Docker)
- Docker and Docker Compose (recommended for easy setup and deployment)
- Clone the repository:
git clone https://github.com/your-username/node-drive.git cd node-drive - Install NPM packages (if running without Docker):
npm install
- Google OAuth 2.0 Credentials: This application uses Google for authentication. You need to set up your own Google API project to obtain your Client ID and Client Secret.
- Go to the Google Cloud Console.
- Create a new project or select an existing one.
- Navigate to "APIs & Services" > "Credentials".
- Create an "OAuth client ID" of type "Web application".
- Add your authorized redirect URIs (e.g.,
http://localhost:3000/auth/google/callback).
- Environment Variables: Create a
.envfile in the root directory and add the following:Replace placeholders with your actual values.ADMIN_EMAIL=your_admin_email@example.com GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret SESSION_SECRET=your_super_secret_key_hereSESSION_SECRETshould be a strong, random string used for securing session cookies.
This project can be easily run using Docker and Docker Compose.
-
Build and Run with Docker Compose: Ensure you have Docker and Docker Compose installed. Navigate to the root directory of the project where
docker-compose.ymlis located.docker-compose up --build
This command will build the Docker image (if not already built or if changes are detected) and start the container. The application will be accessible at
http://localhost:3000.Note: A
.dockerignorefile is included to optimize Docker image builds by excluding unnecessary files and directories. -
Volumes: The
uploadsanddatadirectories are configured as Docker volumes to persist your uploaded files and application data outside the container. This means your data will not be lost if the container is removed.
To start the application:
npm startThen, open your web browser and navigate to http://localhost:3000.
For running with Docker Compose, please refer to the Docker Setup section.
expressexpress-sessionmulterpassportpassport-google-oauth20
Distributed under the MIT License. See LICENSE for more information.