Skip to content

roilanrodriguez55/FileServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FileServer

A modern web-based file sharing platform with user authentication and role-based access control.

Features

Authentication & Security

  • User Registration: Users can create accounts with username and password
  • Secure Login: Password hashing using bcrypt
  • Session Management: Secure session-based authentication
  • Role-Based Access Control: Two user roles (Admin and User)

File Management

  • File Upload: Drag & drop or click to browse (Admin only)
  • File Sharing: All authenticated users can view and download shared files
  • File Deletion: Administrators can delete files
  • File Search: Search functionality to filter files
  • Multiple File Support: Upload multiple files at once

User Interface

  • Modern UI: Clean and responsive design with gradient backgrounds
  • Real-time Updates: File list updates automatically
  • User Dashboard: Shows user information and role badge
  • Responsive Design: Works on different screen sizes

Installation

Prerequisites

  • Node.js (v12 or higher) - Download here
  • npm (comes with Node.js)

Setup Steps

  1. Clone or download the repository

    cd FileServer
  2. Install dependencies

    npm install
  3. Start the server

    npm start

    Or:

    node fileServer.js [port]

    Default port is 3000 if not specified.

  4. Access the application

    • Open your browser and navigate to: http://localhost:3000
    • Or from another machine on the same network: http://your_ip_address:3000

Default Credentials

A default administrator account is created automatically:

  • Username: admin
  • Password: admin

⚠️ Important: Change the default admin password after first login in production environments.

User Roles

Administrator

  • Upload files
  • View all shared files
  • Download files
  • Delete files
  • Full access to all features

User

  • View all shared files
  • Download files
  • Limited access (no upload/delete)

Usage

First Time Setup

  1. Start the server using npm start
  2. Navigate to the login page
  3. Login with the default admin credentials
  4. Upload files using the drag & drop area
  5. Register new users from the registration page

For Administrators

  1. Upload Files:

    • Click on the upload area or drag & drop files
    • Select multiple files if needed
    • Click "Upload Files" button
  2. Manage Files:

    • View all shared files in the list
    • Search for specific files using the search bar
    • Delete files using the "Delete" button
    • Download files using the "Download" button

For Regular Users

  1. View Files:

    • Login to your account
    • Browse all shared files
    • Use the search bar to find specific files
  2. Download Files:

    • Click the "Download" button on any file
    • Or click "Open" for PDF and JS files to view in browser

Project Structure

FileServer/
├── fileServer.js          # Main server file
├── package.json            # Dependencies and scripts
├── users.json              # User database (auto-generated)
├── Share/                  # Directory for shared files
├── Record/                 # Directory for chat records
├── views/                  # EJS templates
│   ├── index.ejs          # Main application page
│   ├── login.ejs          # Login page
│   └── register.ejs        # Registration page
├── scripts/                # Client-side JavaScript
│   ├── script.js          # Main application logic
│   └── query.js           # Additional utilities
└── styles/                # CSS stylesheets
    └── style.css          # Main stylesheet

Configuration

Port Configuration

The server runs on port 3000 by default. To use a different port:

node fileServer.js 8080

User Database

Users are stored in users.json in the project root. The file is automatically created with a default admin user on first run.

File Storage

Uploaded files are stored in the Share/ directory. Make sure this directory has write permissions.

Security Notes

  • Passwords are hashed using bcrypt (10 rounds)
  • Sessions expire after 24 hours
  • File uploads are restricted to administrators only
  • File deletion requires administrator privileges
  • All routes are protected with authentication middleware

Dependencies

  • express: Web framework
  • express-session: Session management
  • bcrypt: Password hashing
  • multer: File upload handling
  • ejs: Template engine
  • fs-extra: Enhanced file system operations
  • body-parser: Request body parsing

Deployment

Docker

Check the Docker configuration in prod/docker/dockerfile for containerized deployment.

Windows Background Service

Use prod/windows/runInBackground.vbs to run the server as a background service on Windows.

Future Improvements

  • Progress bar while uploading
  • Folder upload support
  • File type filtering (documents, images, software, etc.)
  • User-specific file permissions
  • File versioning
  • Activity logs
  • Email notifications
  • Two-factor authentication
  • API endpoints for programmatic access

License

This project is open source and available for use and modification.

Support

For issues or questions, please check the code comments or create an issue in the repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published