summaryrefslogtreecommitdiff
path: root/README.md
blob: 1b0f2cf235ddfb583d7191c491c81d2e40aa9691 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File Upload Application (Deno)

A basic file uploading website demonstration, built with Deno and Oak.

## Features (Phase 1) ✓

- **Dual Upload Modes**:
  - Simple upload page (no JavaScript required)
  - JavaScript version with chunked uploads for large files
- **Multiple File Support**: Upload one or multiple files at once
- **File Sharing**: After upload, get shareable URLs for downloaded files
- **File Browser**: Browse all uploaded files with size and timestamp info
- **Error Handling**: Appropriate error reporting and comprehensive logging
- **Configurable Limits**:
  - File size limit (default: 100MB) - defined in `config.ts`
  - File type restrictions (configurable in `config.ts`)
  - File expiration (default: 7 days)
- **Rate Limiting**: Per IP address (default: 10 uploads per 15 minutes)
- **Smart Naming**: Files keep original names unless collision occurs, then epoch seconds are appended
- **Auto Cleanup**: Expired files are automatically removed

## Getting Started

### Prerequisites

- Deno 2.0+ installed ([https://deno.land](https://deno.land))

### Running the Server

Development mode (with auto-reload):
```bash
deno task dev
```

Production mode:
```bash
deno task start
```

The server will start at `http://localhost:8000`

## Configuration

Edit `config.ts` to customize:

- **Port**: Server port (default: 8000)
- **Upload Directory**: Where files are stored (default: ./uploads)
- **Max File Size**: Maximum file size in bytes (default: 100MB)
- **Allowed File Types**: Array of MIME types (default: all types allowed)
- **File Expiration**: Time before files are deleted in ms (default: 7 days)
- **Rate Limiting**: Window and max uploads per IP
- **Chunk Size**: Size of chunks for chunked uploads (default: 1MB)

## API Endpoints

- `GET /` - Simple upload page
- `GET /chunked` - Chunked upload page
- `GET /browse` - Browse all uploaded files
- `POST /upload` - Upload files (multipart/form-data)
- `POST /upload-chunk` - Upload file chunks
- `GET /download/:filename` - Download a file

## Phase 2 (Planned)

- Database integration to store file metadata
- File model and controller
- IP address tracking and association with uploads
- Page visit tracking by IP
- Enhanced analytics and reporting

## Project Structure

```
.
├── main.ts           # Main server and routes
├── config.ts         # Configuration settings
├── logger.ts         # Logging utility
├── rateLimiter.ts    # Rate limiting logic
├── fileUtils.ts      # File handling utilities
├── views.ts          # HTML template rendering
├── deno.json         # Deno configuration
└── uploads/          # Uploaded files directory (auto-created)
```

## Security Features

- Rate limiting per IP address
- File size validation
- File type validation
- Automatic file expiration
- Comprehensive logging of all operations