mirror of
https://github.com/vastsa/FileCodeBox.git
synced 2026-11-24 08:07:01 +08:00
docs: rename legacy camelCase config keys to snake_case in guides
Sync zh/en guide docs with migration 007 key names (upload_size, open_upload, enable_chunk, expire_style, error_count, etc.) so existing deployments following the docs use the current schema.
This commit is contained in:
1 parent
6e7580b8dc
commit
8972344235
12 files changed
+218
-218
No files matched your search
@@ -22,9 +22,9 @@ On first startup, the system uses default configuration from `core/settings.py`.
|
||||
| `name` | string | `文件快递柜 - FileCodeBox` | Site name, displayed in page title and navigation bar |
|
||||
| `description` | string | `开箱即用的文件快传系统` | Site description, used for SEO |
|
||||
| `keywords` | string | `FileCodeBox, 文件快递柜...` | Site keywords, used for SEO |
|
||||
| `serverHost` | string | `0.0.0.0` | Service listening address |
|
||||
| `serverPort` | int | `12345` | Service listening port |
|
||||
| `serverWorkers` | int | `1` | Worker count; keep one worker for SQLite deployments |
|
||||
| `server_host` | string | `0.0.0.0` | Service listening address |
|
||||
| `server_port` | int | `12345` | Service listening port |
|
||||
| `server_workers` | int | `1` | Worker count; keep one worker for SQLite deployments |
|
||||
|
||||
### Notification Settings
|
||||
|
||||
@@ -33,7 +33,7 @@ On first startup, the system uses default configuration from `core/settings.py`.
|
||||
| `notify_title` | string | `系统通知` | Notification title |
|
||||
| `notify_content` | string | Welcome message | Notification content, supports HTML |
|
||||
| `page_explain` | string | Legal disclaimer | Footer explanation text |
|
||||
| `robotsText` | string | `User-agent: *\nDisallow: /` | robots.txt content |
|
||||
| `robots_text` | string | `User-agent: *\nDisallow: /` | robots.txt content |
|
||||
|
||||
## Upload Settings
|
||||
|
||||
@@ -41,21 +41,21 @@ On first startup, the system uses default configuration from `core/settings.py`.
|
||||
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `openUpload` | int | `1` | Enable upload functionality (1=enabled, 0=disabled) |
|
||||
| `uploadSize` | int | `10485760` | Maximum single file upload size (bytes), default 10MB |
|
||||
| `enableChunk` | int | `0` | Enable chunked upload (1=enabled, 0=disabled) |
|
||||
| `open_upload` | int | `1` | Enable upload functionality (1=enabled, 0=disabled) |
|
||||
| `upload_size` | int | `10485760` | Maximum single file upload size (bytes), default 10MB |
|
||||
| `enable_chunk` | int | `0` | Enable chunked upload (1=enabled, 0=disabled) |
|
||||
| `allowed_file_types` | list | `["*"]` | Allowed extensions; `*` allows every file type |
|
||||
|
||||
::: warning Note
|
||||
`uploadSize` is in bytes. 10MB = 10 * 1024 * 1024 = 10485760 bytes
|
||||
`upload_size` is in bytes. 10MB = 10 * 1024 * 1024 = 10485760 bytes
|
||||
:::
|
||||
|
||||
### Upload Rate Limiting
|
||||
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `uploadMinute` | int | `1` | Upload limit time window (minutes) |
|
||||
| `uploadCount` | int | `10` | Maximum uploads allowed within the time window |
|
||||
| `upload_minute` | int | `1` | Upload limit time window (minutes) |
|
||||
| `upload_count` | int | `10` | Maximum uploads allowed within the time window |
|
||||
|
||||
Example: Default configuration allows up to 10 uploads per minute.
|
||||
|
||||
@@ -64,7 +64,7 @@ Example: Default configuration allows up to 10 uploads per minute.
|
||||
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `expireStyle` | list | `["day","hour","minute","forever","count"]` | Available expiration methods |
|
||||
| `expire_style` | list | `["day","hour","minute","forever","count"]` | Available expiration methods |
|
||||
| `max_save_seconds` | int | `0` | Maximum file retention time (seconds), 0 means no limit |
|
||||
|
||||
Expiration methods explained:
|
||||
@@ -80,8 +80,8 @@ Expiration methods explained:
|
||||
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `themesSelect` | string | `themes/2024` | Currently active theme |
|
||||
| `themesChoices` | list | See below | Available themes list |
|
||||
| `themes_select` | string | `themes/2024` | Currently active theme |
|
||||
| `themes_choices` | list | See below | Available themes list |
|
||||
|
||||
Default available themes:
|
||||
```json
|
||||
@@ -113,8 +113,8 @@ Default available themes:
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `admin_token` | string | Set during setup | Admin login password |
|
||||
| `showAdminAddr` | int | `0` | Show admin panel entry on homepage (1=show, 0=hide) |
|
||||
| `adminSessionExpire` | int | `2592000` | Admin session lifetime in seconds (30 days) |
|
||||
| `show_admin_addr` | int | `0` | Show admin panel entry on homepage (1=show, 0=hide) |
|
||||
| `admin_session_expire` | int | `2592000` | Admin session lifetime in seconds (30 days) |
|
||||
|
||||
::: danger Security Warning
|
||||
The setup page is shown automatically while the system is uninitialized. Complete setup before exposing a production service to the public internet.
|
||||
@@ -126,9 +126,9 @@ The setup page is shown automatically while the system is uninitialized. Complet
|
||||
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `errorMinute` | int | `1` | Error limit time window (minutes) |
|
||||
| `errorCount` | int | `10` | Maximum errors allowed within the time window |
|
||||
| `trustedProxies` | list | `[]` | Trusted reverse-proxy IPs used to resolve client addresses |
|
||||
| `error_minute` | int | `1` | Error limit time window (minutes) |
|
||||
| `error_count` | int | `10` | Maximum errors allowed within the time window |
|
||||
| `trusted_proxies` | list | `[]` | Trusted reverse-proxy IPs used to resolve client addresses |
|
||||
|
||||
This setting prevents brute-force attacks on extraction codes.
|
||||
|
||||
@@ -140,7 +140,7 @@ This setting prevents brute-force attacks on extraction codes.
|
||||
|---------|------|---------|-------------|
|
||||
| `file_storage` | string | `local` | Storage backend type |
|
||||
| `storage_path` | string | `""` | Custom storage path |
|
||||
| `storageLimit` | int | `0` | Total storage quota in bytes; 0 means unlimited |
|
||||
| `storage_limit` | int | `0` | Total storage quota in bytes; 0 means unlimited |
|
||||
|
||||
Supported storage types:
|
||||
- `local` - Local storage
|
||||
@@ -160,11 +160,11 @@ Suitable for personal or small team use with relaxed limits:
|
||||
```python
|
||||
{
|
||||
"name": "My File Share",
|
||||
"uploadSize": 52428800, # 50MB
|
||||
"uploadMinute": 5, # 5 minutes
|
||||
"uploadCount": 20, # Max 20 uploads
|
||||
"expireStyle": ["day", "hour", "forever"],
|
||||
"showAdminAddr": 1
|
||||
"upload_size": 52428800, # 50MB
|
||||
"upload_minute": 5, # 5 minutes
|
||||
"upload_count": 20, # Max 20 uploads
|
||||
"expire_style": ["day", "hour", "forever"],
|
||||
"show_admin_addr": 1
|
||||
}
|
||||
```
|
||||
|
||||
@@ -175,14 +175,14 @@ Suitable for public services requiring stricter limits:
|
||||
```python
|
||||
{
|
||||
"name": "Public File Box",
|
||||
"uploadSize": 10485760, # 10MB
|
||||
"uploadMinute": 1, # 1 minute
|
||||
"uploadCount": 5, # Max 5 uploads
|
||||
"errorMinute": 5, # 5 minutes
|
||||
"errorCount": 3, # Max 3 errors
|
||||
"expireStyle": ["hour", "minute", "count"],
|
||||
"upload_size": 10485760, # 10MB
|
||||
"upload_minute": 1, # 1 minute
|
||||
"upload_count": 5, # Max 5 uploads
|
||||
"error_minute": 5, # 5 minutes
|
||||
"error_count": 3, # Max 3 errors
|
||||
"expire_style": ["hour", "minute", "count"],
|
||||
"max_save_seconds": 86400, # Max retention 1 day
|
||||
"showAdminAddr": 0
|
||||
"show_admin_addr": 0
|
||||
}
|
||||
```
|
||||
|
||||
@@ -193,13 +193,13 @@ Suitable for enterprise internal use with large file and chunked upload support:
|
||||
```python
|
||||
{
|
||||
"name": "Enterprise File Transfer",
|
||||
"uploadSize": 1073741824, # 1GB
|
||||
"enableChunk": 1, # Enable chunked upload
|
||||
"uploadMinute": 10, # 10 minutes
|
||||
"uploadCount": 100, # Max 100 uploads
|
||||
"expireStyle": ["day", "forever"],
|
||||
"upload_size": 1073741824, # 1GB
|
||||
"enable_chunk": 1, # Enable chunked upload
|
||||
"upload_minute": 10, # 10 minutes
|
||||
"upload_count": 100, # Max 100 uploads
|
||||
"expire_style": ["day", "forever"],
|
||||
"file_storage": "s3", # Use S3 storage
|
||||
"showAdminAddr": 1
|
||||
"show_admin_addr": 1
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ npm run dev
|
||||
## ❓ FAQ
|
||||
|
||||
### Q: How to modify upload size limit?
|
||||
A: Change `uploadSize` in admin panel
|
||||
A: Change `upload_size` in admin panel
|
||||
|
||||
### Q: How to configure storage engine?
|
||||
A: Select storage engine and configure parameters in admin panel
|
||||
|
||||
@@ -27,10 +27,10 @@ By default, the admin panel entry is not shown on the homepage. You can control
|
||||
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `showAdminAddr` | int | `0` | Show admin entry on homepage (1=show, 0=hide) |
|
||||
| `show_admin_addr` | int | `0` | Show admin entry on homepage (1=show, 0=hide) |
|
||||
|
||||
::: warning Security Recommendation
|
||||
For public services, it's recommended to keep `showAdminAddr` at `0` and access the admin panel directly via the `/admin` path to reduce the risk of malicious scanning.
|
||||
For public services, it's recommended to keep `show_admin_addr` at `0` and access the admin panel directly via the `/admin` path to reduce the risk of malicious scanning.
|
||||
:::
|
||||
|
||||
### Authentication Mechanism
|
||||
@@ -240,15 +240,15 @@ Administrators can modify most configurations through the admin panel:
|
||||
| Category | Example Settings |
|
||||
|----------|------------------|
|
||||
| Basic Settings | `name`, `description`, `keywords`, `notify_title`, `notify_content` |
|
||||
| Upload Settings | `uploadSize`, `uploadMinute`, `uploadCount`, `openUpload`, `enableChunk` |
|
||||
| Expiration Settings | `expireStyle`, `max_save_seconds` |
|
||||
| Theme Settings | `themesSelect`, `opacity`, `background` |
|
||||
| Security Settings | `admin_token`, `showAdminAddr`, `errorMinute`, `errorCount` |
|
||||
| Upload Settings | `upload_size`, `upload_minute`, `upload_count`, `open_upload`, `enable_chunk` |
|
||||
| Expiration Settings | `expire_style`, `max_save_seconds` |
|
||||
| Theme Settings | `themes_select`, `opacity`, `background` |
|
||||
| Security Settings | `admin_token`, `show_admin_addr`, `error_minute`, `error_count` |
|
||||
| Storage Settings | `file_storage`, `storage_path` and storage backend-specific configurations |
|
||||
|
||||
::: warning Note
|
||||
- `admin_token` (admin password) cannot be set to empty
|
||||
- `themesChoices` (theme list) cannot be modified through the admin panel
|
||||
- `themes_choices` (theme list) cannot be modified through the admin panel
|
||||
- After modifying storage settings, existing files will not be automatically migrated
|
||||
:::
|
||||
|
||||
@@ -382,7 +382,7 @@ Content-Type: application/json
|
||||
|
||||
{
|
||||
"admin_token": "new-password",
|
||||
"uploadSize": 52428800
|
||||
"upload_size": 52428800
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+40
-40
@@ -34,14 +34,14 @@ Change the admin password through the admin panel:
|
||||
|
||||
### Hide Admin Entry
|
||||
|
||||
By default, the admin panel entry is hidden. You can control whether to show the admin entry on the homepage via the `showAdminAddr` configuration:
|
||||
By default, the admin panel entry is hidden. You can control whether to show the admin entry on the homepage via the `show_admin_addr` configuration:
|
||||
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `showAdminAddr` | int | `0` | Show admin entry (1=show, 0=hide) |
|
||||
| `show_admin_addr` | int | `0` | Show admin entry (1=show, 0=hide) |
|
||||
|
||||
::: tip Recommendation
|
||||
For public services, it's recommended to keep `showAdminAddr` at `0` and access the admin panel directly via the `/admin` path.
|
||||
For public services, it's recommended to keep `show_admin_addr` at `0` and access the admin panel directly via the `/admin` path.
|
||||
:::
|
||||
|
||||
## IP Rate Limiting
|
||||
@@ -54,12 +54,12 @@ Limit the number of uploads from a single IP within a specified time:
|
||||
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `uploadMinute` | int | `1` | Upload limit time window (minutes) |
|
||||
| `uploadCount` | int | `10` | Maximum uploads allowed within the time window |
|
||||
| `upload_minute` | int | `1` | Upload limit time window (minutes) |
|
||||
| `upload_count` | int | `10` | Maximum uploads allowed within the time window |
|
||||
|
||||
**How it works:**
|
||||
- System records upload requests from each IP
|
||||
- When an IP's upload count reaches `uploadCount` within `uploadMinute` minutes
|
||||
- When an IP's upload count reaches `upload_count` within `upload_minute` minutes
|
||||
- Subsequent upload requests from that IP will be rejected with HTTP 423 error
|
||||
- Counter resets after the time window expires
|
||||
|
||||
@@ -68,14 +68,14 @@ Limit the number of uploads from a single IP within a specified time:
|
||||
```python
|
||||
# Relaxed configuration: Max 20 uploads in 5 minutes
|
||||
{
|
||||
"uploadMinute": 5,
|
||||
"uploadCount": 20
|
||||
"upload_minute": 5,
|
||||
"upload_count": 20
|
||||
}
|
||||
|
||||
# Strict configuration: Max 3 uploads in 1 minute
|
||||
{
|
||||
"uploadMinute": 1,
|
||||
"uploadCount": 3
|
||||
"upload_minute": 1,
|
||||
"upload_count": 3
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,13 +86,13 @@ Limit the number of error attempts from a single IP to prevent brute-force attac
|
||||
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `errorMinute` | int | `1` | Error limit time window (minutes) |
|
||||
| `errorCount` | int | `10` | Maximum errors allowed within the time window |
|
||||
| `error_minute` | int | `1` | Error limit time window (minutes) |
|
||||
| `error_count` | int | `10` | Maximum errors allowed within the time window |
|
||||
|
||||
**How it works:**
|
||||
- When a user enters an incorrect extraction code, the system records the error count for that IP
|
||||
- When error count reaches `errorCount`, that IP will be temporarily locked
|
||||
- Lock duration is `errorMinute` minutes
|
||||
- When error count reaches `error_count`, that IP will be temporarily locked
|
||||
- Lock duration is `error_minute` minutes
|
||||
- During lockout, all extraction requests from that IP will be rejected
|
||||
|
||||
**Configuration example:**
|
||||
@@ -100,8 +100,8 @@ Limit the number of error attempts from a single IP to prevent brute-force attac
|
||||
```python
|
||||
# Anti-brute-force configuration: Max 3 errors in 5 minutes
|
||||
{
|
||||
"errorMinute": 5,
|
||||
"errorCount": 3
|
||||
"error_minute": 5,
|
||||
"error_count": 3
|
||||
}
|
||||
```
|
||||
|
||||
@@ -115,8 +115,8 @@ The default allows up to 10 errors per IP each minute. Public services can tight
|
||||
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `uploadSize` | int | `10485760` | Maximum single file upload size (bytes), default 10MB |
|
||||
| `openUpload` | int | `1` | Enable upload functionality (1=enabled, 0=disabled) |
|
||||
| `upload_size` | int | `10485760` | Maximum single file upload size (bytes), default 10MB |
|
||||
| `open_upload` | int | `1` | Enable upload functionality (1=enabled, 0=disabled) |
|
||||
|
||||
**Common size conversions:**
|
||||
- 10MB = 10 * 1024 * 1024 = `10485760`
|
||||
@@ -130,7 +130,7 @@ Through file expiration mechanisms, you can automatically clean up expired files
|
||||
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `expireStyle` | list | `["day","hour","minute","forever","count"]` | Available expiration methods |
|
||||
| `expire_style` | list | `["day","hour","minute","forever","count"]` | Available expiration methods |
|
||||
| `max_save_seconds` | int | `0` | Maximum file retention time (seconds), 0 means no limit |
|
||||
|
||||
**Expiration methods explained:**
|
||||
@@ -150,7 +150,7 @@ For public services, it's recommended to:
|
||||
```python
|
||||
# Recommended configuration for public services
|
||||
{
|
||||
"expireStyle": ["hour", "minute", "count"],
|
||||
"expire_style": ["hour", "minute", "count"],
|
||||
"max_save_seconds": 86400 # Max retention 1 day
|
||||
}
|
||||
```
|
||||
@@ -161,7 +161,7 @@ In some cases, you may need to temporarily disable upload functionality:
|
||||
|
||||
```python
|
||||
{
|
||||
"openUpload": 0 # Disable upload functionality
|
||||
"open_upload": 0 # Disable upload functionality
|
||||
}
|
||||
```
|
||||
|
||||
@@ -197,7 +197,7 @@ server {
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
# Limit request body size (match uploadSize configuration)
|
||||
# Limit request body size (match upload_size configuration)
|
||||
client_max_body_size 100M;
|
||||
|
||||
# Pass real IP
|
||||
@@ -236,7 +236,7 @@ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
**2. Request Body Size Limit**
|
||||
|
||||
Nginx's `client_max_body_size` should match or be slightly larger than FileCodeBox's `uploadSize` configuration:
|
||||
Nginx's `client_max_body_size` should match or be slightly larger than FileCodeBox's `upload_size` configuration:
|
||||
|
||||
```nginx
|
||||
client_max_body_size 100M; # Allow max 100MB uploads
|
||||
@@ -269,7 +269,7 @@ your-domain.com {
|
||||
Before deploying FileCodeBox, confirm the following security configurations:
|
||||
|
||||
- [ ] Completed first-run setup and set the admin password `admin_token`
|
||||
- [ ] Hidden admin entry `showAdminAddr: 0`
|
||||
- [ ] Hidden admin entry `show_admin_addr: 0`
|
||||
- [ ] Configured appropriate upload rate limiting
|
||||
- [ ] Configured error rate limiting to prevent brute-force attacks
|
||||
- [ ] Set reasonable file size limits
|
||||
@@ -285,15 +285,15 @@ Before deploying FileCodeBox, confirm the following security configurations:
|
||||
```python
|
||||
{
|
||||
"admin_token": "your-very-secure-password",
|
||||
"showAdminAddr": 0,
|
||||
"uploadSize": 10485760, # 10MB
|
||||
"uploadMinute": 1,
|
||||
"uploadCount": 5,
|
||||
"errorMinute": 5,
|
||||
"errorCount": 3,
|
||||
"expireStyle": ["hour", "minute", "count"],
|
||||
"show_admin_addr": 0,
|
||||
"upload_size": 10485760, # 10MB
|
||||
"upload_minute": 1,
|
||||
"upload_count": 5,
|
||||
"error_minute": 5,
|
||||
"error_count": 3,
|
||||
"expire_style": ["hour", "minute", "count"],
|
||||
"max_save_seconds": 86400, # Max 1 day
|
||||
"openUpload": 1
|
||||
"open_upload": 1
|
||||
}
|
||||
```
|
||||
|
||||
@@ -302,15 +302,15 @@ Before deploying FileCodeBox, confirm the following security configurations:
|
||||
```python
|
||||
{
|
||||
"admin_token": "internal-secure-password",
|
||||
"showAdminAddr": 1,
|
||||
"uploadSize": 104857600, # 100MB
|
||||
"uploadMinute": 5,
|
||||
"uploadCount": 50,
|
||||
"errorMinute": 1,
|
||||
"errorCount": 5,
|
||||
"expireStyle": ["day", "hour", "forever"],
|
||||
"show_admin_addr": 1,
|
||||
"upload_size": 104857600, # 100MB
|
||||
"upload_minute": 5,
|
||||
"upload_count": 50,
|
||||
"error_minute": 1,
|
||||
"error_count": 5,
|
||||
"expire_style": ["day", "hour", "forever"],
|
||||
"max_save_seconds": 0, # No limit
|
||||
"openUpload": 1
|
||||
"open_upload": 1
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -66,10 +66,10 @@ Response example:
|
||||
|
||||
### File Size Limit
|
||||
|
||||
The default maximum single file upload size is **10MB**. Administrators can modify this limit via the `uploadSize` configuration.
|
||||
The default maximum single file upload size is **10MB**. Administrators can modify this limit via the `upload_size` configuration.
|
||||
|
||||
::: tip Tip
|
||||
If you need to upload large files, contact the administrator to enable chunked upload functionality or adjust the `uploadSize` configuration.
|
||||
If you need to upload large files, contact the administrator to enable chunked upload functionality or adjust the `upload_size` configuration.
|
||||
:::
|
||||
|
||||
### Supported Upload Methods
|
||||
@@ -116,7 +116,7 @@ FileCodeBox supports multiple flexible expiration methods:
|
||||
| By Count | `count` | File expires after specified download count |
|
||||
|
||||
::: info Note
|
||||
- Administrators can control available expiration methods via the `expireStyle` configuration
|
||||
- Administrators can control available expiration methods via the `expire_style` configuration
|
||||
- Administrators can limit maximum file retention time via the `max_save_seconds` configuration
|
||||
:::
|
||||
|
||||
@@ -208,7 +208,7 @@ This endpoint returns file content directly, suitable for direct browser access.
|
||||
|
||||
## Chunked Upload (Large Files)
|
||||
|
||||
For large file uploads, FileCodeBox supports chunked upload functionality. This feature requires administrator enablement (`enableChunk=1`).
|
||||
For large file uploads, FileCodeBox supports chunked upload functionality. This feature requires administrator enablement (`enable_chunk=1`).
|
||||
|
||||
### Chunked Upload Flow
|
||||
|
||||
|
||||
+19
-19
@@ -51,7 +51,7 @@ Paste upload only supports image formats, not other file types. Specific support
|
||||
|
||||
| Setting | Default | Description |
|
||||
|---------|---------|-------------|
|
||||
| `uploadSize` | 10MB | Maximum single file upload size |
|
||||
| `upload_size` | 10MB | Maximum single file upload size |
|
||||
|
||||
### Modify Upload Limits
|
||||
|
||||
@@ -59,11 +59,11 @@ Administrators can modify upload size limits through the admin panel or configur
|
||||
|
||||
```python
|
||||
# Set maximum upload size to 100MB
|
||||
uploadSize = 104857600 # 100 * 1024 * 1024
|
||||
upload_size = 104857600 # 100 * 1024 * 1024
|
||||
```
|
||||
|
||||
::: info Note
|
||||
`uploadSize` is in bytes. Common conversions:
|
||||
`upload_size` is in bytes. Common conversions:
|
||||
- 10MB = 10485760
|
||||
- 50MB = 52428800
|
||||
- 100MB = 104857600
|
||||
@@ -147,7 +147,7 @@ curl -L "http://localhost:12345/share/select/?code=YOUR_CODE" -o downloaded_file
|
||||
```
|
||||
|
||||
::: tip When Authentication Required
|
||||
If guest upload is disabled in admin panel (`openUpload=0`), you need to login first:
|
||||
If guest upload is disabled in admin panel (`open_upload=0`), you need to login first:
|
||||
|
||||
```bash
|
||||
# 1. Login to get token
|
||||
@@ -175,7 +175,7 @@ curl -X POST "http://localhost:12345/share/text/" \
|
||||
For large files, FileCodeBox supports chunked upload functionality. Chunked upload splits large files into multiple small chunks for separate uploading, supporting resume capability.
|
||||
|
||||
::: warning Prerequisite
|
||||
Chunked upload functionality requires administrator enablement: `enableChunk=1`
|
||||
Chunked upload functionality requires administrator enablement: `enable_chunk=1`
|
||||
:::
|
||||
|
||||
### Chunked Upload Flow
|
||||
@@ -363,7 +363,7 @@ await fetch(`/chunk/upload/complete/${upload_id}`, {
|
||||
|
||||
| HTTP Status | Error Message | Cause | Solution |
|
||||
|-------------|---------------|-------|----------|
|
||||
| 403 | Size exceeds limit | File exceeds `uploadSize` limit | Reduce file size or contact administrator to adjust limit |
|
||||
| 403 | Size exceeds limit | File exceeds `upload_size` limit | Reduce file size or contact administrator to adjust limit |
|
||||
| 403 | Upload rate limit | Exceeded IP upload rate limit | Wait for limit time window before retrying |
|
||||
| 400 | Invalid expiration type | `expire_style` value not in allowed list | Use a valid expiration method |
|
||||
| 404 | Upload session not found | `upload_id` invalid or expired | Re-initialize upload |
|
||||
@@ -376,8 +376,8 @@ The system has rate limits on upload operations to prevent abuse:
|
||||
|
||||
| Setting | Default | Description |
|
||||
|---------|---------|-------------|
|
||||
| `uploadMinute` | 1 | Limit time window (minutes) |
|
||||
| `uploadCount` | 10 | Maximum uploads within time window |
|
||||
| `upload_minute` | 1 | Limit time window (minutes) |
|
||||
| `upload_count` | 10 | Maximum uploads within time window |
|
||||
|
||||
When rate limit is exceeded, you need to wait for the time window to pass before continuing uploads.
|
||||
|
||||
@@ -395,26 +395,26 @@ When rate limit is exceeded, you need to wait for the time window to pass before
|
||||
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| `openUpload` | int | 1 | Enable upload (1=enabled, 0=disabled) |
|
||||
| `uploadSize` | int | 10485760 | Maximum upload size (bytes) |
|
||||
| `enableChunk` | int | 0 | Enable chunked upload (1=enabled, 0=disabled) |
|
||||
| `uploadMinute` | int | 1 | Upload rate limit time window (minutes) |
|
||||
| `uploadCount` | int | 10 | Maximum uploads within time window |
|
||||
| `expireStyle` | list | ["day","hour","minute","forever","count"] | Allowed expiration methods |
|
||||
| `open_upload` | int | 1 | Enable upload (1=enabled, 0=disabled) |
|
||||
| `upload_size` | int | 10485760 | Maximum upload size (bytes) |
|
||||
| `enable_chunk` | int | 0 | Enable chunked upload (1=enabled, 0=disabled) |
|
||||
| `upload_minute` | int | 1 | Upload rate limit time window (minutes) |
|
||||
| `upload_count` | int | 10 | Maximum uploads within time window |
|
||||
| `expire_style` | list | ["day","hour","minute","forever","count"] | Allowed expiration methods |
|
||||
|
||||
### Configuration Example
|
||||
|
||||
```python
|
||||
# Allow 100MB file uploads, enable chunked upload
|
||||
uploadSize = 104857600
|
||||
enableChunk = 1
|
||||
upload_size = 104857600
|
||||
enable_chunk = 1
|
||||
|
||||
# Relax upload rate limit: max 50 uploads per 5 minutes
|
||||
uploadMinute = 5
|
||||
uploadCount = 50
|
||||
upload_minute = 5
|
||||
upload_count = 50
|
||||
|
||||
# Only allow expiration by days and count
|
||||
expireStyle = ["day", "count"]
|
||||
expire_style = ["day", "count"]
|
||||
```
|
||||
|
||||
## Next Steps
|
||||
|
||||
+37
-37
@@ -22,9 +22,9 @@ FileCodeBox 支持两种配置方式:
|
||||
| `name` | string | `文件快递柜 - FileCodeBox` | 站点名称,显示在页面标题和导航栏 |
|
||||
| `description` | string | `开箱即用的文件快传系统` | 站点描述,用于 SEO |
|
||||
| `keywords` | string | `FileCodeBox, 文件快递柜...` | 站点关键词,用于 SEO |
|
||||
| `serverHost` | string | `0.0.0.0` | 服务监听地址 |
|
||||
| `serverPort` | int | `12345` | 服务监听端口 |
|
||||
| `serverWorkers` | int | `1` | 工作进程数;SQLite 部署建议保持单进程 |
|
||||
| `server_host` | string | `0.0.0.0` | 服务监听地址 |
|
||||
| `server_port` | int | `12345` | 服务监听端口 |
|
||||
| `server_workers` | int | `1` | 工作进程数;SQLite 部署建议保持单进程 |
|
||||
|
||||
### 通知设置
|
||||
|
||||
@@ -33,7 +33,7 @@ FileCodeBox 支持两种配置方式:
|
||||
| `notify_title` | string | `系统通知` | 通知标题 |
|
||||
| `notify_content` | string | 欢迎信息 | 通知内容,支持 HTML |
|
||||
| `page_explain` | string | 法律声明 | 页面底部说明文字 |
|
||||
| `robotsText` | string | `User-agent: *\nDisallow: /` | robots.txt 内容 |
|
||||
| `robots_text` | string | `User-agent: *\nDisallow: /` | robots.txt 内容 |
|
||||
|
||||
## 上传设置
|
||||
|
||||
@@ -41,21 +41,21 @@ FileCodeBox 支持两种配置方式:
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `openUpload` | int | `1` | 是否开启上传功能(1=开启,0=关闭) |
|
||||
| `uploadSize` | int | `10485760` | 单文件最大上传大小(字节),默认 10MB |
|
||||
| `enableChunk` | int | `0` | 是否启用分片上传(1=启用,0=禁用) |
|
||||
| `open_upload` | int | `1` | 是否开启上传功能(1=开启,0=关闭) |
|
||||
| `upload_size` | int | `10485760` | 单文件最大上传大小(字节),默认 10MB |
|
||||
| `enable_chunk` | int | `0` | 是否启用分片上传(1=启用,0=禁用) |
|
||||
| `allowed_file_types` | list | `["*"]` | 允许上传的扩展名;`*` 表示不限制 |
|
||||
|
||||
::: warning 注意
|
||||
`uploadSize` 的单位是字节。10MB = 10 * 1024 * 1024 = 10485760 字节
|
||||
`upload_size` 的单位是字节。10MB = 10 * 1024 * 1024 = 10485760 字节
|
||||
:::
|
||||
|
||||
### 上传频率限制
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `uploadMinute` | int | `1` | 上传限制的时间窗口(分钟) |
|
||||
| `uploadCount` | int | `10` | 在时间窗口内允许的最大上传次数 |
|
||||
| `upload_minute` | int | `1` | 上传限制的时间窗口(分钟) |
|
||||
| `upload_count` | int | `10` | 在时间窗口内允许的最大上传次数 |
|
||||
|
||||
例如:默认配置表示每 1 分钟内最多允许上传 10 次。
|
||||
|
||||
@@ -63,7 +63,7 @@ FileCodeBox 支持两种配置方式:
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `expireStyle` | list | `["day","hour","minute","forever","count"]` | 可选的过期方式 |
|
||||
| `expire_style` | list | `["day","hour","minute","forever","count"]` | 可选的过期方式 |
|
||||
| `max_save_seconds` | int | `0` | 文件最大保存时间(秒),0 表示不限制 |
|
||||
|
||||
过期方式说明:
|
||||
@@ -79,8 +79,8 @@ FileCodeBox 支持两种配置方式:
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `themesSelect` | string | `themes/2024` | 当前使用的主题 |
|
||||
| `themesChoices` | list | 见下方 | 可用主题列表 |
|
||||
| `themes_select` | string | `themes/2024` | 当前使用的主题 |
|
||||
| `themes_choices` | list | 见下方 | 可用主题列表 |
|
||||
|
||||
默认可用主题:
|
||||
```json
|
||||
@@ -112,8 +112,8 @@ FileCodeBox 支持两种配置方式:
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `admin_token` | string | 初始化页面设置 | 管理员登录密码(哈希存储) |
|
||||
| `showAdminAddr` | int | `0` | 是否在首页显示管理入口(1=显示,0=隐藏) |
|
||||
| `adminSessionExpire` | int | `2592000` | 管理会话有效期(秒),默认 30 天 |
|
||||
| `show_admin_addr` | int | `0` | 是否在首页显示管理入口(1=显示,0=隐藏) |
|
||||
| `admin_session_expire` | int | `2592000` | 管理会话有效期(秒),默认 30 天 |
|
||||
|
||||
::: danger 安全警告
|
||||
未初始化时会自动显示初始化页面。生产环境请在服务对外开放前完成初始化。
|
||||
@@ -125,9 +125,9 @@ FileCodeBox 支持两种配置方式:
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `errorMinute` | int | `1` | 错误限制的时间窗口(分钟) |
|
||||
| `errorCount` | int | `10` | 在时间窗口内允许的最大错误次数 |
|
||||
| `trustedProxies` | list | `[]` | 可信反向代理 IP;用于安全解析客户端地址 |
|
||||
| `error_minute` | int | `1` | 错误限制的时间窗口(分钟) |
|
||||
| `error_count` | int | `10` | 在时间窗口内允许的最大错误次数 |
|
||||
| `trusted_proxies` | list | `[]` | 可信反向代理 IP;用于安全解析客户端地址 |
|
||||
|
||||
此设置用于防止暴力破解提取码。
|
||||
|
||||
@@ -139,7 +139,7 @@ FileCodeBox 支持两种配置方式:
|
||||
|--------|------|--------|------|
|
||||
| `file_storage` | string | `local` | 存储后端类型 |
|
||||
| `storage_path` | string | `""` | 自定义存储路径 |
|
||||
| `storageLimit` | int | `0` | 总存储配额(字节),0 表示不限制 |
|
||||
| `storage_limit` | int | `0` | 总存储配额(字节),0 表示不限制 |
|
||||
|
||||
支持的存储类型:
|
||||
- `local` - 本地存储
|
||||
@@ -159,11 +159,11 @@ FileCodeBox 支持两种配置方式:
|
||||
```python
|
||||
{
|
||||
"name": "我的文件分享",
|
||||
"uploadSize": 52428800, # 50MB
|
||||
"uploadMinute": 5, # 5分钟
|
||||
"uploadCount": 20, # 最多20次
|
||||
"expireStyle": ["day", "hour", "forever"],
|
||||
"showAdminAddr": 1
|
||||
"upload_size": 52428800, # 50MB
|
||||
"upload_minute": 5, # 5分钟
|
||||
"upload_count": 20, # 最多20次
|
||||
"expire_style": ["day", "hour", "forever"],
|
||||
"show_admin_addr": 1
|
||||
}
|
||||
```
|
||||
|
||||
@@ -174,14 +174,14 @@ FileCodeBox 支持两种配置方式:
|
||||
```python
|
||||
{
|
||||
"name": "公共文件快递柜",
|
||||
"uploadSize": 10485760, # 10MB
|
||||
"uploadMinute": 1, # 1分钟
|
||||
"uploadCount": 5, # 最多5次
|
||||
"errorMinute": 5, # 5分钟
|
||||
"errorCount": 3, # 最多3次错误
|
||||
"expireStyle": ["hour", "minute", "count"],
|
||||
"upload_size": 10485760, # 10MB
|
||||
"upload_minute": 1, # 1分钟
|
||||
"upload_count": 5, # 最多5次
|
||||
"error_minute": 5, # 5分钟
|
||||
"error_count": 3, # 最多3次错误
|
||||
"expire_style": ["hour", "minute", "count"],
|
||||
"max_save_seconds": 86400, # 最长保存1天
|
||||
"showAdminAddr": 0
|
||||
"show_admin_addr": 0
|
||||
}
|
||||
```
|
||||
|
||||
@@ -192,13 +192,13 @@ FileCodeBox 支持两种配置方式:
|
||||
```python
|
||||
{
|
||||
"name": "企业文件中转站",
|
||||
"uploadSize": 1073741824, # 1GB
|
||||
"enableChunk": 1, # 启用分片上传
|
||||
"uploadMinute": 10, # 10分钟
|
||||
"uploadCount": 100, # 最多100次
|
||||
"expireStyle": ["day", "forever"],
|
||||
"upload_size": 1073741824, # 1GB
|
||||
"enable_chunk": 1, # 启用分片上传
|
||||
"upload_minute": 10, # 10分钟
|
||||
"upload_count": 100, # 最多100次
|
||||
"expire_style": ["day", "forever"],
|
||||
"file_storage": "s3", # 使用S3存储
|
||||
"showAdminAddr": 1
|
||||
"show_admin_addr": 1
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ npm run dev
|
||||
## ❓ 常见问题
|
||||
|
||||
### Q: 如何修改上传大小限制?
|
||||
A: 在管理面板中修改配置项 `uploadSize`
|
||||
A: 在管理面板中修改配置项 `upload_size`
|
||||
|
||||
### Q: 如何配置存储引擎?
|
||||
A: 在管理面板中选择存储引擎并配置相应参数
|
||||
|
||||
@@ -27,10 +27,10 @@ FileCodeBox 提供了功能完善的管理面板,让管理员可以方便地
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `showAdminAddr` | int | `0` | 是否在首页显示管理入口(1=显示,0=隐藏) |
|
||||
| `show_admin_addr` | int | `0` | 是否在首页显示管理入口(1=显示,0=隐藏) |
|
||||
|
||||
::: warning 安全建议
|
||||
在公开服务中,建议保持 `showAdminAddr` 为 `0`,通过直接访问 `/admin` 路径进入管理面板,减少被恶意扫描的风险。
|
||||
在公开服务中,建议保持 `show_admin_addr` 为 `0`,通过直接访问 `/admin` 路径进入管理面板,减少被恶意扫描的风险。
|
||||
:::
|
||||
|
||||
### 认证机制
|
||||
@@ -239,15 +239,15 @@ FileCodeBox 提供了功能完善的管理面板,让管理员可以方便地
|
||||
| 类别 | 配置项示例 |
|
||||
|------|------------|
|
||||
| 基础设置 | `name`, `description`, `keywords`, `notify_title`, `notify_content` |
|
||||
| 上传设置 | `uploadSize`, `uploadMinute`, `uploadCount`, `openUpload`, `enableChunk` |
|
||||
| 过期设置 | `expireStyle`, `max_save_seconds` |
|
||||
| 主题设置 | `themesSelect`, `opacity`, `background` |
|
||||
| 安全设置 | `admin_token`, `showAdminAddr`, `errorMinute`, `errorCount` |
|
||||
| 上传设置 | `upload_size`, `upload_minute`, `upload_count`, `open_upload`, `enable_chunk` |
|
||||
| 过期设置 | `expire_style`, `max_save_seconds` |
|
||||
| 主题设置 | `themes_select`, `opacity`, `background` |
|
||||
| 安全设置 | `admin_token`, `show_admin_addr`, `error_minute`, `error_count` |
|
||||
| 存储设置 | `file_storage`, `storage_path` 及各存储后端的配置 |
|
||||
|
||||
::: warning 注意
|
||||
- `admin_token`(管理员密码)不能设置为空
|
||||
- `themesChoices`(主题列表)不可通过管理面板修改
|
||||
- `themes_choices`(主题列表)不可通过管理面板修改
|
||||
- 修改存储设置后,已有文件不会自动迁移
|
||||
:::
|
||||
|
||||
@@ -381,7 +381,7 @@ Content-Type: application/json
|
||||
|
||||
{
|
||||
"admin_token": "new-password",
|
||||
"uploadSize": 52428800
|
||||
"upload_size": 52428800
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+40
-40
@@ -34,14 +34,14 @@ FileCodeBox 首次启动时不会生成默认管理员密码。请在浏览器
|
||||
|
||||
### 隐藏管理入口
|
||||
|
||||
默认情况下,管理面板入口是隐藏的。您可以通过 `showAdminAddr` 配置控制是否在首页显示管理入口:
|
||||
默认情况下,管理面板入口是隐藏的。您可以通过 `show_admin_addr` 配置控制是否在首页显示管理入口:
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `showAdminAddr` | int | `0` | 是否显示管理入口(1=显示,0=隐藏) |
|
||||
| `show_admin_addr` | int | `0` | 是否显示管理入口(1=显示,0=隐藏) |
|
||||
|
||||
::: tip 建议
|
||||
在公开服务中,建议保持 `showAdminAddr` 为 `0`,通过直接访问 `/admin` 路径进入管理面板。
|
||||
在公开服务中,建议保持 `show_admin_addr` 为 `0`,通过直接访问 `/admin` 路径进入管理面板。
|
||||
:::
|
||||
|
||||
## IP 速率限制
|
||||
@@ -54,12 +54,12 @@ FileCodeBox 内置了基于 IP 的速率限制机制,可以有效防止滥用
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `uploadMinute` | int | `1` | 上传限制的时间窗口(分钟) |
|
||||
| `uploadCount` | int | `10` | 在时间窗口内允许的最大上传次数 |
|
||||
| `upload_minute` | int | `1` | 上传限制的时间窗口(分钟) |
|
||||
| `upload_count` | int | `10` | 在时间窗口内允许的最大上传次数 |
|
||||
|
||||
**工作原理:**
|
||||
- 系统记录每个 IP 的上传请求
|
||||
- 当某 IP 在 `uploadMinute` 分钟内的上传次数达到 `uploadCount` 时
|
||||
- 当某 IP 在 `upload_minute` 分钟内的上传次数达到 `upload_count` 时
|
||||
- 该 IP 的后续上传请求将被拒绝,返回 HTTP 423 错误
|
||||
- 等待时间窗口过期后,计数器重置
|
||||
|
||||
@@ -68,14 +68,14 @@ FileCodeBox 内置了基于 IP 的速率限制机制,可以有效防止滥用
|
||||
```python
|
||||
# 宽松配置:5分钟内最多上传20次
|
||||
{
|
||||
"uploadMinute": 5,
|
||||
"uploadCount": 20
|
||||
"upload_minute": 5,
|
||||
"upload_count": 20
|
||||
}
|
||||
|
||||
# 严格配置:1分钟内最多上传3次
|
||||
{
|
||||
"uploadMinute": 1,
|
||||
"uploadCount": 3
|
||||
"upload_minute": 1,
|
||||
"upload_count": 3
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,13 +85,13 @@ FileCodeBox 内置了基于 IP 的速率限制机制,可以有效防止滥用
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `errorMinute` | int | `1` | 错误限制的时间窗口(分钟) |
|
||||
| `errorCount` | int | `10` | 在时间窗口内允许的最大错误次数 |
|
||||
| `error_minute` | int | `1` | 错误限制的时间窗口(分钟) |
|
||||
| `error_count` | int | `10` | 在时间窗口内允许的最大错误次数 |
|
||||
|
||||
**工作原理:**
|
||||
- 当用户输入错误的提取码时,系统记录该 IP 的错误次数
|
||||
- 当错误次数达到 `errorCount` 时,该 IP 将被暂时锁定
|
||||
- 锁定时间为 `errorMinute` 分钟
|
||||
- 当错误次数达到 `error_count` 时,该 IP 将被暂时锁定
|
||||
- 锁定时间为 `error_minute` 分钟
|
||||
- 锁定期间,该 IP 的所有提取请求都将被拒绝
|
||||
|
||||
**配置示例:**
|
||||
@@ -99,8 +99,8 @@ FileCodeBox 内置了基于 IP 的速率限制机制,可以有效防止滥用
|
||||
```python
|
||||
# 防暴力破解配置:5分钟内最多允许3次错误
|
||||
{
|
||||
"errorMinute": 5,
|
||||
"errorCount": 3
|
||||
"error_minute": 5,
|
||||
"error_count": 3
|
||||
}
|
||||
```
|
||||
|
||||
@@ -114,8 +114,8 @@ FileCodeBox 内置了基于 IP 的速率限制机制,可以有效防止滥用
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `uploadSize` | int | `10485760` | 单文件最大上传大小(字节),默认 10MB |
|
||||
| `openUpload` | int | `1` | 是否开启上传功能(1=开启,0=关闭) |
|
||||
| `upload_size` | int | `10485760` | 单文件最大上传大小(字节),默认 10MB |
|
||||
| `open_upload` | int | `1` | 是否开启上传功能(1=开启,0=关闭) |
|
||||
|
||||
**常用大小换算:**
|
||||
- 10MB = 10 * 1024 * 1024 = `10485760`
|
||||
@@ -129,7 +129,7 @@ FileCodeBox 内置了基于 IP 的速率限制机制,可以有效防止滥用
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `expireStyle` | list | `["day","hour","minute","forever","count"]` | 可选的过期方式 |
|
||||
| `expire_style` | list | `["day","hour","minute","forever","count"]` | 可选的过期方式 |
|
||||
| `max_save_seconds` | int | `0` | 文件最大保存时间(秒),0 表示不限制 |
|
||||
|
||||
**过期方式说明:**
|
||||
@@ -149,7 +149,7 @@ FileCodeBox 内置了基于 IP 的速率限制机制,可以有效防止滥用
|
||||
```python
|
||||
# 公开服务推荐配置
|
||||
{
|
||||
"expireStyle": ["hour", "minute", "count"],
|
||||
"expire_style": ["hour", "minute", "count"],
|
||||
"max_save_seconds": 86400 # 最长保存1天
|
||||
}
|
||||
```
|
||||
@@ -160,7 +160,7 @@ FileCodeBox 内置了基于 IP 的速率限制机制,可以有效防止滥用
|
||||
|
||||
```python
|
||||
{
|
||||
"openUpload": 0 # 关闭上传功能
|
||||
"open_upload": 0 # 关闭上传功能
|
||||
}
|
||||
```
|
||||
|
||||
@@ -196,7 +196,7 @@ server {
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
# 限制请求体大小(与 uploadSize 配置一致)
|
||||
# 限制请求体大小(与 upload_size 配置一致)
|
||||
client_max_body_size 100M;
|
||||
|
||||
# 传递真实 IP
|
||||
@@ -235,7 +235,7 @@ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
**2. 请求体大小限制**
|
||||
|
||||
Nginx 的 `client_max_body_size` 应该与 FileCodeBox 的 `uploadSize` 配置一致或略大:
|
||||
Nginx 的 `client_max_body_size` 应该与 FileCodeBox 的 `upload_size` 配置一致或略大:
|
||||
|
||||
```nginx
|
||||
client_max_body_size 100M; # 允许上传最大 100MB
|
||||
@@ -268,7 +268,7 @@ your-domain.com {
|
||||
部署 FileCodeBox 前,请确认以下安全配置:
|
||||
|
||||
- [ ] 已完成首次初始化并设置管理员密码 `admin_token`
|
||||
- [ ] 已隐藏管理入口 `showAdminAddr: 0`
|
||||
- [ ] 已隐藏管理入口 `show_admin_addr: 0`
|
||||
- [ ] 已配置合适的上传频率限制
|
||||
- [ ] 已配置错误次数限制防止暴力破解
|
||||
- [ ] 已设置合理的文件大小限制
|
||||
@@ -284,15 +284,15 @@ your-domain.com {
|
||||
```python
|
||||
{
|
||||
"admin_token": "your-very-secure-password",
|
||||
"showAdminAddr": 0,
|
||||
"uploadSize": 10485760, # 10MB
|
||||
"uploadMinute": 1,
|
||||
"uploadCount": 5,
|
||||
"errorMinute": 5,
|
||||
"errorCount": 3,
|
||||
"expireStyle": ["hour", "minute", "count"],
|
||||
"show_admin_addr": 0,
|
||||
"upload_size": 10485760, # 10MB
|
||||
"upload_minute": 1,
|
||||
"upload_count": 5,
|
||||
"error_minute": 5,
|
||||
"error_count": 3,
|
||||
"expire_style": ["hour", "minute", "count"],
|
||||
"max_save_seconds": 86400, # 最长1天
|
||||
"openUpload": 1
|
||||
"open_upload": 1
|
||||
}
|
||||
```
|
||||
|
||||
@@ -301,15 +301,15 @@ your-domain.com {
|
||||
```python
|
||||
{
|
||||
"admin_token": "internal-secure-password",
|
||||
"showAdminAddr": 1,
|
||||
"uploadSize": 104857600, # 100MB
|
||||
"uploadMinute": 5,
|
||||
"uploadCount": 50,
|
||||
"errorMinute": 1,
|
||||
"errorCount": 5,
|
||||
"expireStyle": ["day", "hour", "forever"],
|
||||
"show_admin_addr": 1,
|
||||
"upload_size": 104857600, # 100MB
|
||||
"upload_minute": 5,
|
||||
"upload_count": 50,
|
||||
"error_minute": 1,
|
||||
"error_count": 5,
|
||||
"expire_style": ["day", "hour", "forever"],
|
||||
"max_save_seconds": 0, # 不限制
|
||||
"openUpload": 1
|
||||
"open_upload": 1
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+4
-4
@@ -66,10 +66,10 @@ FileCodeBox 支持两种分享方式:
|
||||
|
||||
### 文件大小限制
|
||||
|
||||
默认单文件最大上传大小为 **10MB**。管理员可以通过 `uploadSize` 配置项修改此限制。
|
||||
默认单文件最大上传大小为 **10MB**。管理员可以通过 `upload_size` 配置项修改此限制。
|
||||
|
||||
::: tip 提示
|
||||
如果需要上传大文件,请联系管理员启用分片上传功能,或调整 `uploadSize` 配置。
|
||||
如果需要上传大文件,请联系管理员启用分片上传功能,或调整 `upload_size` 配置。
|
||||
:::
|
||||
|
||||
### 支持的上传方式
|
||||
@@ -115,7 +115,7 @@ FileCodeBox 支持多种灵活的过期方式:
|
||||
| 按次数过期 | `count` | 文件在被下载指定次数后过期 |
|
||||
|
||||
::: info 说明
|
||||
- 管理员可以通过 `expireStyle` 配置项控制用户可选的过期方式
|
||||
- 管理员可以通过 `expire_style` 配置项控制用户可选的过期方式
|
||||
- 管理员可以通过 `max_save_seconds` 配置项限制文件的最长保存时间
|
||||
:::
|
||||
|
||||
@@ -207,7 +207,7 @@ expire_value=5, expire_style=count
|
||||
|
||||
## 分片上传(大文件)
|
||||
|
||||
对于大文件上传,FileCodeBox 支持分片上传功能。此功能需要管理员启用(`enableChunk=1`)。
|
||||
对于大文件上传,FileCodeBox 支持分片上传功能。此功能需要管理员启用(`enable_chunk=1`)。
|
||||
|
||||
### 分片上传流程
|
||||
|
||||
|
||||
+19
-19
@@ -51,7 +51,7 @@ FileCodeBox 支持以下几种上传方式:
|
||||
|
||||
| 配置项 | 默认值 | 说明 |
|
||||
|--------|--------|------|
|
||||
| `uploadSize` | 10MB | 单文件最大上传大小 |
|
||||
| `upload_size` | 10MB | 单文件最大上传大小 |
|
||||
|
||||
### 修改上传限制
|
||||
|
||||
@@ -59,11 +59,11 @@ FileCodeBox 支持以下几种上传方式:
|
||||
|
||||
```python
|
||||
# 设置最大上传大小为 100MB
|
||||
uploadSize = 104857600 # 100 * 1024 * 1024
|
||||
upload_size = 104857600 # 100 * 1024 * 1024
|
||||
```
|
||||
|
||||
::: info 说明
|
||||
`uploadSize` 的单位是字节。常用换算:
|
||||
`upload_size` 的单位是字节。常用换算:
|
||||
- 10MB = 10485760
|
||||
- 50MB = 52428800
|
||||
- 100MB = 104857600
|
||||
@@ -147,7 +147,7 @@ curl -L "http://localhost:12345/share/select/?code=取件码" -o downloaded_file
|
||||
```
|
||||
|
||||
::: tip 需要认证时
|
||||
如果管理面板关闭了游客上传(`openUpload=0`),需要先登录获取 token:
|
||||
如果管理面板关闭了游客上传(`open_upload=0`),需要先登录获取 token:
|
||||
|
||||
```bash
|
||||
# 1. 登录获取 token
|
||||
@@ -174,7 +174,7 @@ curl -X POST "http://localhost:12345/share/text/" \
|
||||
对于大文件,FileCodeBox 支持分片上传功能。分片上传将大文件分割成多个小块分别上传,支持断点续传。
|
||||
|
||||
::: warning 前提条件
|
||||
分片上传功能需要管理员启用:`enableChunk=1`
|
||||
分片上传功能需要管理员启用:`enable_chunk=1`
|
||||
:::
|
||||
|
||||
### 分片上传流程
|
||||
@@ -362,7 +362,7 @@ await fetch(`/chunk/upload/complete/${upload_id}`, {
|
||||
|
||||
| HTTP 状态码 | 错误信息 | 原因 | 解决方案 |
|
||||
|-------------|----------|------|----------|
|
||||
| 403 | 大小超过限制 | 文件超过 `uploadSize` 限制 | 减小文件大小或联系管理员调整限制 |
|
||||
| 403 | 大小超过限制 | 文件超过 `upload_size` 限制 | 减小文件大小或联系管理员调整限制 |
|
||||
| 403 | 上传频率限制 | 超过 IP 上传频率限制 | 等待限制时间窗口后重试 |
|
||||
| 400 | 过期时间类型错误 | `expire_style` 值不在允许列表中 | 使用有效的过期方式 |
|
||||
| 404 | 上传会话不存在 | `upload_id` 无效或已过期 | 重新初始化上传 |
|
||||
@@ -375,8 +375,8 @@ await fetch(`/chunk/upload/complete/${upload_id}`, {
|
||||
|
||||
| 配置项 | 默认值 | 说明 |
|
||||
|--------|--------|------|
|
||||
| `uploadMinute` | 1 | 限制时间窗口(分钟) |
|
||||
| `uploadCount` | 10 | 时间窗口内最大上传次数 |
|
||||
| `upload_minute` | 1 | 限制时间窗口(分钟) |
|
||||
| `upload_count` | 10 | 时间窗口内最大上传次数 |
|
||||
|
||||
当超过频率限制时,需要等待时间窗口过后才能继续上传。
|
||||
|
||||
@@ -394,26 +394,26 @@ await fetch(`/chunk/upload/complete/${upload_id}`, {
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| `openUpload` | int | 1 | 是否开放上传(1=开放,0=关闭) |
|
||||
| `uploadSize` | int | 10485760 | 最大上传大小(字节) |
|
||||
| `enableChunk` | int | 0 | 是否启用分片上传(1=启用,0=禁用) |
|
||||
| `uploadMinute` | int | 1 | 上传频率限制时间窗口(分钟) |
|
||||
| `uploadCount` | int | 10 | 时间窗口内最大上传次数 |
|
||||
| `expireStyle` | list | ["day","hour","minute","forever","count"] | 允许的过期方式 |
|
||||
| `open_upload` | int | 1 | 是否开放上传(1=开放,0=关闭) |
|
||||
| `upload_size` | int | 10485760 | 最大上传大小(字节) |
|
||||
| `enable_chunk` | int | 0 | 是否启用分片上传(1=启用,0=禁用) |
|
||||
| `upload_minute` | int | 1 | 上传频率限制时间窗口(分钟) |
|
||||
| `upload_count` | int | 10 | 时间窗口内最大上传次数 |
|
||||
| `expire_style` | list | ["day","hour","minute","forever","count"] | 允许的过期方式 |
|
||||
|
||||
### 配置示例
|
||||
|
||||
```python
|
||||
# 允许上传 100MB 文件,启用分片上传
|
||||
uploadSize = 104857600
|
||||
enableChunk = 1
|
||||
upload_size = 104857600
|
||||
enable_chunk = 1
|
||||
|
||||
# 放宽上传频率限制:每 5 分钟最多 50 次
|
||||
uploadMinute = 5
|
||||
uploadCount = 50
|
||||
upload_minute = 5
|
||||
upload_count = 50
|
||||
|
||||
# 只允许按天和按次数过期
|
||||
expireStyle = ["day", "count"]
|
||||
expire_style = ["day", "count"]
|
||||
```
|
||||
|
||||
## 下一步
|
||||
|
||||
Reference in new issue
Block a user