Skip to content

asmith0713/Image_Uploader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¦ TeleBox - MERN Stack

Your personal storage box for Telegram. A full-stack MERN application that uploads images directly to your Telegram chat. Built with React, Express, and Node.js for fast and reliable file sharing.

Features

  • πŸ–ΌοΈ Upload multiple images at once
  • πŸ“€ Automatic upload to Telegram
  • βš›οΈ Modern React frontend with routing
  • 🎨 Beautiful UI with Bootstrap
  • πŸ”’ File type validation (JPG, JPEG, PNG only)
  • πŸš€ Production-ready with build scripts

Tech Stack

Frontend:

  • React 18
  • React Router DOM
  • Axios
  • Bootstrap 5

Backend:

  • Node.js
  • Express
  • Multer (file uploads)
  • node-telegram-bot-api
  • CORS

Prerequisites

  • Node.js (v20.10.0 or higher)
  • A Telegram Bot Token
  • A Telegram Chat ID

Setup Instructions

1. Clone the repository

git clone <repository-url>
cd Image_Uploader

2. Install dependencies

npm run install-all

This will install dependencies for both the server and the client.

3. Configure environment variables

Create a .env file in the root directory:

PORT=5000
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
TELEGRAM_CHAT_ID=your_telegram_chat_id_here
NODE_ENV=development

4. Getting Telegram Credentials

Bot Token:

  1. Open Telegram and search for @BotFather
  2. Send /newbot and follow the instructions
  3. Copy the token provided

Chat ID:

  1. Start a chat with your bot
  2. Send a message to the bot
  3. Visit: https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
  4. Look for the chat.id in the response

Running the Application

Development Mode

Run both client and server concurrently:

npm run dev

Production Mode

  1. Build the React app:
npm run build
  1. Start the server:
npm start

The server will serve the built React app on the configured PORT.

Available Scripts

Script Description
npm start Run the production server
npm run server Run the backend server with nodemon
npm run client Run the React development server
npm run dev Run both client and server concurrently
npm run install-all Install all dependencies (root and client)
npm run build Build the React app for production

Project Structure

Image_Uploader/
β”œβ”€β”€ client/                 # React frontend
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ Upload.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Upload.css
β”‚   β”‚   β”‚   β”œβ”€β”€ ThankYou.js
β”‚   β”‚   β”‚   └── ThankYou.css
β”‚   β”‚   β”œβ”€β”€ App.js
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   └── index.css
β”‚   └── package.json
β”œβ”€β”€ uploads/               # Temporary upload directory (auto-created)
β”œβ”€β”€ server.js              # Express server
β”œβ”€β”€ package.json           # Server dependencies
β”œβ”€β”€ .env                   # Environment variables (not in git)
β”œβ”€β”€ .gitignore
└── README.md

API Endpoints

POST /api/upload

Upload images to Telegram.

Request:

  • Method: POST
  • Content-Type: multipart/form-data
  • Body: Form data with files field (array of images)

Response:

{
  "success": true,
  "message": "Files uploaded successfully"
}

Features Explained

Frontend

  • Upload Component: Handles file selection and upload with validation
  • ThankYou Component: Shows success message with animated checkmark
  • React Router: Provides seamless navigation between pages

Backend

  • Express API: RESTful API endpoint for file uploads
  • Multer: Handles multipart/form-data file uploads
  • Telegram Integration: Automatically sends uploaded files to Telegram
  • File Cleanup: Removes temporary files after upload

Deployment

Heroku

  1. Create a new Heroku app
  2. Add environment variables in Heroku dashboard
  3. Deploy:
git push heroku main

Other Platforms

Make sure to:

  1. Set NODE_ENV=production
  2. Configure all environment variables
  3. Run npm run build before deployment
  4. The app will serve the built React app from the Express server

Troubleshooting

Issue: Files not uploading

  • Check your Telegram credentials in .env
  • Verify the bot has permission to send messages to the chat

Issue: CORS errors

  • Ensure the backend server is running
  • Check that the proxy is configured in client/package.json

Issue: Port already in use

  • Change the PORT in .env file
  • Kill the process using the port: lsof -ti:5000 | xargs kill -9

License

MIT

Author

asmith0713

About

Image Uploader created by using EJS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages