Skip to content

Sumukhapb/FileUpload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 Project Title: File Upload and Temporary Storage

An Express.js application that allows authenticated users to upload, manage, and share files with temporary, expiring links. Supports in-browser previews for common file types and secure downloads for others.

Node.js Express.js MongoDB Passport License

🧰 Tech Stack

✨ Features

  • 🔐 Authentication: Local email/password and Google sign-in
  • ⬆️ Upload: Single-file upload, stored on disk with timestamped filenames
  • 📂 My Files: List files you uploaded
  • 📥 Download: Direct file download
  • ✏️ Rename/Delete: Manage uploaded files (rename and delete)
  • 🔗 Share: Generate temporary shareable links with 24-hour expiry
  • 👀 Preview: Inline previews for text/code, images, and PDFs when possible

🛠️ Prerequisites

  • Node.js v18+ (recommended)
  • npm (comes with Node.js)
  • MongoDB instance (local or hosted)

🚀 Installation and Setup

  1. Clone the repository
git clone https://github.com/Sumukhapb/FileUpload.git
cd Flie_Upload
  1. Install dependencies
npm install
  1. Create an .env file in the project root and configure the environment variables (see next section)

  2. Start the server

# Production
npm start

# Development (auto-restart on changes)
npm run dev
  1. Open the app
  • Visit http://localhost:8000 (default) in your browser

🔧 Environment Variables

Create a .env file with the following keys. Adjust values for your environment.

# Server
PORT=8000

# Database
MONGO_URL=mongodb://127.0.0.1:27017/file_upload

# Google OAuth (for social login)
GOOGLE_CLIENT_ID=<your-google-client-id>
GOOGLE_CLIENT_SECRET=<your-google-client-secret>

Notes:

  • ⚠️ The Google OAuth callback is configured at http://localhost:8000/auth/google/callback. Ensure this is added in your Google Cloud Console OAuth settings.
  • 💾 File uploads are stored on disk under backend/uploads/.

📖 Usage Overview

  • 📝 Sign up with email/password or continue with Google
  • ⬆️ Use the upload page to add files
  • 🧭 Manage your files: rename, delete, download, or generate share links
  • ⏱️ Share links are valid for 24 hours and default to view permission

🔗 API Endpoints

Unless noted, endpoints require authentication via session cookies.

  • Auth

    • GET /auth/login — Render login page
    • GET /auth/signup — Render signup page
    • POST /auth/signup — Create local account and sign in
    • POST /auth/login — Local login
    • GET /auth/google — Start Google OAuth
    • GET /auth/google/callback — Google OAuth callback
    • GET /auth/logout — Log out and destroy session
  • Dashboard

    • GET /dashboard — Authenticated dashboard
  • Files (mounted at /files)

    • GET /files/upload — Upload page
    • POST /files/upload — Upload single file (form field name: file)
    • GET /files/myfiles — List files uploaded by the current user
    • GET /files/download/:filename — Download a file by filename
    • PUT /files/rename/:id — Rename a file by document id (body: { newFileName })
    • DELETE /files/delete/:id — Delete a file by document id
    • POST /files/share/:id — Create a temporary shareable link; returns JSON { link, expireAt }
    • GET /files/shared/:link — Open a shared file (inline preview when supported; otherwise download)
    • GET /files/open-shared?link=<id|url> — Helper route to navigate to a shared file

🖼️ Notes on File Support and Previews

  • ✅ Allowed types include common documents, images, archives, and code/text files
  • 👀 Previews: images (.jpg, .jpeg, .png), text/code (.txt, .js, .css, .html, .py, .java, .cpp, .csv), and PDFs
  • 📦 Archives (.zip, .rar, .7z) show a message when preview is not available

🏃 Scripts

npm start    # start server
npm run dev  # start with nodemon

📄 License

MIT License

👤 Author

Sumukh PB

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published