Skip to content

πŸ’» Electron + Express Image Uploader β€”Built with Electron (frontend) + Express.js (backend) + Multer (file handling).

Notifications You must be signed in to change notification settings

TheekshanaCN/electron-image-uploader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Electron + Express Image Uploader

πŸš€ A complete desktop application for uploading and managing images
πŸ“Œ Built with Electron (frontend) + Express.js (backend)
πŸ”’ Secure file handling with Multer and CORS


✨ Features

βœ”οΈ Image Upload - Drag & drop or file selection
βœ”οΈ Live Preview - See images before uploading
βœ”οΈ Gallery View - Display all uploaded images
βœ”οΈ Cross-Platform - Works on Windows, macOS, and Linux
βœ”οΈ Auto-Save - Files stored in ~/electron-uploads


πŸš€ Quick Start

1. Clone the Repository

git clone https://github.com/TheekshanaCN/electron-image-uploader.git
cd electron-image-uploader

2. Install Dependencies

npm install

3. Run the App

npm start

For development, use npm run dev with nodemon for live reloading

4. Build for Production

npm run build

Generates executables for Windows, macOS, and Linux


πŸ“‚ Project Structure

electron-image-uploader/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.js           # Electron main process
β”‚   β”œβ”€β”€ api.js            # Express backend
β”‚   β”œβ”€β”€ preload.js        # Secure IPC bridge
β”‚   └── renderer/
β”‚       β”œβ”€β”€ index.html    # Frontend UI
β”‚       └── renderer.js   # Frontend logic
β”œβ”€β”€ package.json
└── README.md

πŸ”§ Configuration

Change Upload Directory

Modify UPLOADS_DIR in api.js:

const UPLOADS_DIR = path.join(os.homedir(), 'your-custom-folder');

Allowed File Types

Edit the fileFilter in api.js to restrict file types:

fileFilter: (req, file, cb) => {
  if (file.mimetype.startsWith('image/')) cb(null, true);
  else cb(new Error('Only images (JPEG, PNG, GIF) allowed!'), false);
}

πŸ’‘ How It Works

Frontend (Electron)

  • Uses HTML/CSS/JS for UI
  • Communicates with Express via IPC
  • Displays previews and gallery

Backend (Express)

  • Handles file uploads with Multer
  • Serves images via API (/api/upload, /api/images/:filename)
  • Stores files in ~/electron-uploads

Security

  • CORS enabled for safe API requests
  • File validation (only images allowed)
  • Context Isolation (Electron security best practice)

πŸ“¦ Packaging for Distribution

Build platform-specific executables:

npm run build:win   # Windows (NSIS)
npm run build:mac   # macOS (DMG)
npm run build:linux # Linux (AppImage)

(Requires electron-builder – already included in package.json)


πŸ›  Troubleshooting

❌ "API not ready" error

Ensure Express starts before the Electron window (check main.js)

❌ Upload fails silently

Check DevTools (Ctrl+Shift+I) for errors
Verify UPLOADS_DIR exists and is writable

❌ Build errors

Make sure icon.ico exists in src/assets/


πŸ“œ License

MIT Β© TheekshanaCN


Happy Coding! πŸŽ¨πŸš€


πŸ–Ό Preview

Preview

About

πŸ’» Electron + Express Image Uploader β€”Built with Electron (frontend) + Express.js (backend) + Multer (file handling).

Topics

Resources

Stars

Watchers

Forks