Skip to content

Repository files navigation

🚀 bashupload - High-Performance File Uploader

A blazing-fast, secure file uploader built with Go and Fiber that supports files up to 50GB with a beautiful terminal-style web interface and powerful CLI tool - inspired by bashupload.com.

Go VersionFiberLicenseDocker

✨ Features

  • 🚀 High Performance - Built with Fiber for lightning-fast uploads
  • 📁 Configurable File Size - Upload limit configurable via environment (default 1GB)
  • 🔗 Secure Links - Unique download URLs with original file extensions
  • Auto-Expiry - Files expire after 3 days and configurable download limit
  • 🔐 API Authentication - Optional API key protection for private instances
  • 💻 CLI Tool - Powerful command-line interface with progress bars
  • 🌐 Terminal Web Interface - Retro terminal-style web UI inspired by bashupload
  • 📊 Progress Tracking - Real-time upload/download progress
  • 🗄️ SQLite Database - Lightweight database for metadata storage
  • 🐳 Docker Ready - Complete containerization support
  • 🔄 Cross-Platform - Works on Linux, macOS, and Windows

📸 Screenshots

Web Interface

  • Terminal-style retro interface inspired by bashupload.com
  • Green-on-black matrix-style design with monospace fonts
  • Real-time progress bars for uploads
  • Instant shareable download links with file extensions
  • Single download policy - files are removed after first download

CLI Tool

$ ./bashupload upload largefile.zip
📁 Uploading: largefile.zip (500 MB)
Uploading... ████████████████████████████████████████ 100% | 500 MB/500 MB
✅ Upload successful!
📄 File: largefile.zip
📏 Size: 500 MB
🆔 ID: a1b2c3d4e5f6g7h8
🔗 Download URL: http://localhost:3000/d/a1b2c3d4e5f6g7h8.zip

🚀 Quick Start

Using Docker (Recommended)

# Clone the repository
git clone https://github.com/yourusername/bashupload.git
cd bashupload
# Start with Docker Compose
make compose-up
# Or manually with Docker
make docker-run

Manual Installation

# Clone the repository
git clone https://github.com/yourusername/bashupload.git
cd bashupload
# Install dependencies
make deps
# Build the project
make build
# Run the server
make run

The server will start on http://localhost:3000

📖 Usage

Web Interface

  1. Open http://localhost:3000 in your browser
  2. Drag and drop files or click to select
  3. Upload files up to 10GB
  4. Get instant shareable download links

CLI Tool

Upload a file

./bashupload upload path/to/your/file.zip

Upload with API key (for private instances)

./bashupload upload file.txt --api-key your_secret_key

Upload with custom server

./bashupload upload file.txt --server https://your-domain.com --api-key your_key

Get file information

./bashupload info a1b2c3d4e5f6g7h8

Download a file

./bashupload download a1b2c3d4e5f6g7h8.zip output.zip

CLI Help

./bashupload --help

API Endpoints

Upload File (with optional API key)

POST /api/upload
Content-Type: multipart/form-data
X-API-Key: your_secret_key (if required)
curl -X POST -F "file=@example.zip" -H "X-API-Key: your_key" http://localhost:3000/api/upload

Upload via cURL (bashupload style)

# Public instance
curl http://localhost:3000 -T your_file.txt
# Private instance
curl -H "X-API-Key: your_key" http://localhost:3000 -T your_file.txt

Download File

GET /d/{filename-with-extension}
GET /download/{filename-with-extension}

Get File Info

GET /api/files/{file-id}

Get Statistics

GET /api/stats

🛠️ Development

Prerequisites

  • Go 1.21+
  • SQLite3
  • Docker (optional)
  • Make (optional, for convenience commands)

Development Setup

# Clone repository
git clone https://github.com/yourusername/bashupload.git
cd bashupload
# Install dependencies
make deps
# Run in development mode (with auto-reload)
make dev

Building

# Build for current platform
make build
# Build for specific platforms
make build-linux
make build-windows
make build-darwin
# Create release package
make release

Testing

# Run tests
make test# Run tests with coverage
make test-coverage
# Run benchmarks
make benchmark

🐳 Docker

Docker Compose (Recommended)

version: '3.8'services:
fileuploader:
build: .ports:
- "3000:3000"volumes:
- ./uploads:/app/uploads
- ./fileuploader.db:/app/fileuploader.dbrestart: unless-stopped
# Start services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down

Manual Docker

# Build image
docker build -t bashupload .# Run container
docker run -d \
--name bashupload \
-p 3000:3000 \
-v $(pwd)/uploads:/app/uploads \
-v $(pwd)/bashupload.db:/app/bashupload.db \
bashupload

⚙️ Configuration

Environment Variables

VariableDefaultDescription
PORT3000Server port
MAX_UPLOAD_SIZE1GBMaximum upload size (supports: 100MB, 1GB, 5GB, etc.)
MAX_DOWNLOADS1Number of times file can be downloaded before deletion
FILE_EXPIRE_AFTER3DFile expiration time (supports: 1D, 1W, 1M, 1Y, etc.)
API_KEY""API key for authentication (optional)
GIN_MODEdebugGin mode (debug/release)

Upload Size Configuration

You can configure the maximum upload size using human-readable strings:

# Set to 5GBexport MAX_UPLOAD_SIZE=5GB
# Set to 100MBexport MAX_UPLOAD_SIZE=100MB
# Set to 500MBexport MAX_UPLOAD_SIZE=500MB
# Set to 2.5GB (decimal supported)export MAX_UPLOAD_SIZE=2.5GB
# Still supports bytes if you preferexport MAX_UPLOAD_SIZE=1073741824

Supported formats:

  • Bytes: 1024, 1073741824
  • Kilobytes: 100K, 100KB, 100KiB
  • Megabytes: 100M, 100MB, 100MiB
  • Gigabytes: 1G, 1GB, 1GiB, 2.5GB
  • Terabytes: 1T, 1TB, 1TiB

Case insensitive: 1gb, 1GB, 1Gb all work the same

Private Instance Setup

To run a private instance that requires API key authentication:

# Set API key environment variableexport API_KEY="your_super_secret_api_key_here"# Set custom upload limit (human readable)export MAX_UPLOAD_SIZE=5GB
# Allow multiple downloads per fileexport MAX_DOWNLOADS=5
# Set custom expiration timeexport FILE_EXPIRE_AFTER=1W
# Run bashupload server
./bashupload-server

Or with Docker:

# Edit docker-compose.yml and set environment variables
docker-compose up -d

Example configurations:

# Quick sharing: 1 hour, single download, small filesexport MAX_UPLOAD_SIZE=50MB
export MAX_DOWNLOADS=1
export FILE_EXPIRE_AFTER=1H
./bashupload-server
# Team sharing: 1 week, multiple downloads, larger files export MAX_UPLOAD_SIZE=2.5GB
export MAX_DOWNLOADS=10
export FILE_EXPIRE_AFTER=1W
./bashupload-server
# Long-term storage: 6 months, unlimited downloadsexport MAX_UPLOAD_SIZE=1GB
export MAX_DOWNLOADS=999
export FILE_EXPIRE_AFTER=6MO
./bashupload-server
# Archive sharing: 1 year, 100 downloads, large filesexport MAX_UPLOAD_SIZE=10GB
export MAX_DOWNLOADS=100
export FILE_EXPIRE_AFTER=1Y
./bashupload-server

Or with Docker:

# Edit docker-compose.yml and uncomment API_KEY line
docker-compose up -d

Server Configuration

The server can be configured by environment variables:

  • Upload Limit: Configurable via MAX_UPLOAD_SIZE (default 1GB)
  • Download Limit: Configurable via MAX_DOWNLOADS (default 1)
  • File Expiration: Configurable via FILE_EXPIRE_AFTER (default 3 days)
  • Timeouts: Read/Write timeout set to 30 minutes
  • Rate Limiting: 100 requests per minute per IP

📁 Project Structure

bashupload/
├── main.go # Main server application
├── cmd/cli/main.go # CLI application
├── templates/
│ └── index.html # Web interface template
├── static/
│ └── style.css # Terminal-style CSS
├── go.mod # Go module definition
├── go.sum # Go module checksums
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
├── Makefile # Build and development commands
├── setup.sh # Project setup script
├── README.md # This file
├── uploads/ # Upload directory (created automatically)
└── bashupload.db # SQLite database (created automatically)

🔧 API Reference

Upload Response

{
"success": true,
"message": "File uploaded successfully",
"unique_id": "a1b2c3d4e5f6g7h8",
"download_url": "http://localhost:3000/d/a1b2c3d4e5f6g7h8",
"file_size": 1048576
}

File Information Response

{
"success": true,
"data": {
"id": 1,
"unique_id": "a1b2c3d4e5f6g7h8",
"original_name": "example.zip",
"file_size": 1048576,
"mime_type": "application/zip",
"extension": ".zip",
"uploaded_at": "2023-12-07T10:30:00Z",
"downloads": 5
}
}

🚀 Performance

  • Concurrent uploads: Supports multiple simultaneous uploads
  • Streaming: Uses streaming for memory-efficient large file handling
  • Progress tracking: Real-time progress updates
  • Rate limiting: Built-in protection against abuse
  • Compression: Automatic response compression

Benchmarks

  • Upload Speed: Up to 1GB/s (network dependent)
  • Memory Usage: ~50MB base memory
  • Concurrent Users: 1000+ simultaneous connections
  • File Size: Tested with files up to 10GB

🛡️ Security Features

  • Rate limiting: Protection against spam uploads
  • File size validation: Prevents oversized uploads
  • Unique file IDs: Cryptographically secure random IDs
  • CORS protection: Configurable cross-origin policies
  • Input validation: Comprehensive request validation

🐛 Troubleshooting

Common Issues

Upload fails with large files

  • Check available disk space
  • Increase Docker container memory if using Docker
  • Verify network timeout settings

CLI connection errors

# Check server URL
./uploader upload file.txt --server http://correct-url:3000 --verbose

Database locked errors

# Reset database
make db-reset

Docker container issues

# Check logs
docker-compose logs fileuploader
# Restart container
docker-compose restart fileuploader

Debug Mode

Enable verbose logging:

# CLI
./uploader upload file.txt --verbose
# Server
PORT=3000 GIN_MODE=debug ./server

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow Go conventions
  • Add tests for new features
  • Update documentation
  • Use meaningful commit messages

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ and Go - Inspired by bashupload.com

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages