Skip to content

sidamo82/docker_container_http_uploader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Resumable File Upload Server

A Docker container that provides an HTTP upload interface with support for large files (up to 10GB), real-time progress tracking, upload speed monitoring, and resume functionality.

Features

  • Large File Support: Upload files up to 10GB
  • Resume Capability: Resume interrupted uploads
  • Real-time Progress: Live progress bar with percentage
  • Speed Monitoring: Real-time upload speed display
  • Drag & Drop: Modern drag-and-drop interface
  • Long Timeouts: Extended HTTP timeouts for large files
  • Chunked Upload: Efficient chunked upload mechanism
  • File Management: View and download uploaded files
  • Responsive Design: Works on desktop and mobile

Quick Start

Using Docker Compose (Recommended)

  1. Clone or download the project files
  2. Run the container:
docker-compose up -d
  1. Open your browser and navigate to http://localhost:3000

Using Docker

# Build the image
docker build -t upload-server .

# Run the container
docker run -d \
  -p 3000:3000 \
  -v $(pwd)/uploads:/app/uploads \
  -v $(pwd)/temp:/app/temp \
  --name upload-server \
  upload-server

Manual Setup

# Install dependencies
npm install

# Start the server
npm start

Usage

  1. Select File: Click the upload area or drag and drop a file
  2. Start Upload: Click "Start Upload" to begin uploading
  3. Monitor Progress: Watch real-time progress, speed, and time remaining
  4. Pause/Resume: Use pause and resume buttons as needed
  5. Download: Access uploaded files from the files list

API Endpoints

Initialize Upload

POST /api/upload/init
Content-Type: application/json

{
  "filename": "example.zip",
  "fileSize": 1073741824,
  "chunkSize": 1048576
}

Upload Chunk

POST /api/upload/chunk
Content-Type: multipart/form-data

- chunk: (file data)
- uploadId: (session ID)
- chunkIndex: (chunk number)
- chunkSize: (chunk size in bytes)

Get Upload Status

GET /api/upload/status/{uploadId}

Resume Upload

GET /api/upload/resume/{uploadId}

List Files

GET /api/files

Download File

GET /api/download/{filename}

Configuration

Environment Variables

  • PORT: Server port (default: 3000)
  • NODE_ENV: Environment mode (production/development)

File Limits

  • Maximum file size: 10GB
  • Chunk size: 1MB (configurable)
  • Session timeout: 1 hour of inactivity

Timeouts

  • HTTP request timeout: 1 hour
  • HTTP response timeout: 1 hour

Architecture

The server uses a chunked upload mechanism:

  1. Initialization: Client requests upload session with file metadata
  2. Chunking: File is split into 1MB chunks on the client side
  3. Upload: Each chunk is uploaded sequentially with progress tracking
  4. Resume: If interrupted, client can resume from the last uploaded chunk
  5. Completion: Once all chunks are uploaded, file is moved to final location

File Storage

  • Uploads: /app/uploads (persistent storage for completed files)
  • Temporary: /app/temp (temporary storage during upload process)

Browser Compatibility

  • Chrome 60+
  • Firefox 55+
  • Safari 12+
  • Edge 79+

Troubleshooting

Upload Fails

  • Check file size (must be ≤ 10GB)
  • Ensure stable internet connection
  • Try resuming the upload

Slow Upload Speed

  • Check network connection
  • Consider reducing chunk size for unstable connections
  • Monitor server resources

Resume Not Working

  • Ensure upload session hasn't expired (1 hour limit)
  • Check that temporary files exist on server

Security Considerations

  • Files are stored in a designated upload directory
  • No file execution permissions
  • Session-based upload tracking
  • Automatic cleanup of expired sessions

Performance Tips

  1. Chunk Size: Default 1MB works well for most connections
  2. Concurrent Uploads: One upload per session to avoid conflicts
  3. Storage: Use fast storage (SSD) for better performance
  4. Network: Stable connection recommended for large files

Development

# Install dependencies
npm install

# Start in development mode
npm run dev

# Build Docker image
docker build -t upload-server .

License

MIT License - feel free to use and modify as needed.

About

Simple HTTP uploader running on docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published