This project implements a simplified Dropbox-like web application where users can upload, download, and view files. It provides a user-friendly interface to interact with a backend server via RESTful APIs to perform file management tasks.
- Upload File: API to upload a file.
- Get List of All Files: API to retrieve a list of all uploaded files.
- Download File: API to download a file by ID.
- Open File: API to view the file contents in a new tab (only for supported file types).
- User Home Page: Displays a list of all user files.
- Supports file upload restrictions.
- Upload New File: A button to allow users to upload files.
- View File: Clicking a file opens the file contents in a new tab (only for supported file types).
- Supported file types:
jpg,jpeg,png,json,pdf,gif.
- Supported file types:
- Language & Framework: Node.js with Express (JavaScript)
- Database: MongoDB
- File Upload Handling: Multer (for file uploads)
- File Storage: Local file system
- Language & Framework: Next.js (TypeScript)
- UI Library: Tailwind CSS
- Node.js (v14.x or higher)
- MongoDB (locally or using Docker)
- npm (Node Package Manager)
-
Clone the Repository:
git clone https://github.com/shivamS21/dropbox.git cd dropbox -
Install Backend Dependencies:
- Navigate to the
backenddirectory and install the required dependencies:
cd backend npm install - Navigate to the
-
Set Up MongoDB:
- Create MongoDB cluster and put its CONNECTION_STRING in .env file.
- Add PORT = 5001 in .env.
-
Start the Backend Server:
- In the
backenddirectory, run the following command:
npm start
This will start the backend server on
http://localhost:5001. - In the
-
Install Frontend Dependencies:
- Navigate to the
frontend_directory and install the required dependencies:
cd ../frontend_ npm install - Navigate to the
-
Start the Frontend Development Server:
- In the
frontend_directory, run the following command:
npm run dev
This will start the frontend development server on
http://localhost:3000. - In the
-
Open the Application:
- Open your browser and go to
http://localhost:3000to access the application. - You can now upload, download, and view files.
- Open your browser and go to
- The following file types are supported for upload:
jpeg,jpeg,jpg,png,gif,pdf, andjson.
- Files of other types will not be accepted for upload.
- The following file types are allowed to be opened in a new tab:
jpeg,jpg,png,gif,pdf, andjson.
- Unsupported file types will prompt an alert that the file cannot be viewed directly.
- POST /api/files/upload
- Allows users to upload a file.
- File type restrictions apply.
- GET /api/files
- Retrieves a list of all files.
- GET /api/files/download/id
- Allows users to download a file by ID.
- GET /api/files/id
- Allows users to view the file contents in a new tab (for supported file types).
- File uploads are handled using Multer, which stores the files in a local directory (
uploads/) on the server. - Upload file restrictions are enforced based on MIME type and file extension, allowing only specific formats (e.g., jpeg, png, gif, pdf, json).
MIT License - Feel free to fork, modify, and use this project!
Thank you for using this Dropbox-like application. Enjoy managing your files!