Skip to content

Commit 3d10957

Browse files
authored
Merge pull request #21 from greirson/even-dumber-drop
feat: Add auto upload configuration and update environment settings
2 parents 432cf7e + 1644749 commit 3d10957

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

.env.example

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# Server Configuration
22
PORT=3000 # The port the server will listen on
3-
DUMBDROP_TITLE=DumbDrop # Site title displayed in header (default: DumbDrop)
43

5-
# Upload Limits
6-
MAX_FILE_SIZE=1024 # Maximum file size in MB (default: 1024 MB / 1 GB)
4+
# Upload Settings
5+
MAX_FILE_SIZE=1024 # Maximum file size in MB
6+
AUTO_UPLOAD=false # Enable automatic upload on file selection
77

88
# Security
9-
DUMBDROP_PIN= # Optional PIN protection (4-10 digits, leave empty to disable)
9+
DUMBDROP_PIN= # Optional PIN protection (4-10 digits)
10+
DUMBDROP_TITLE=DumbDrop # Site title displayed in header
1011

11-
# Notifications
12-
APPRISE_URL= # Apprise URL for notifications (leave empty to disable)
13-
APPRISE_MESSAGE= # Custom message for notifications (default: "New file uploaded: {filename} ({size}), Storage used: {storage}")
14-
APPRISE_SIZE_UNIT= # Size unit for notifications (B, KB, MB, GB, TB). Leave empty for auto
12+
# Notifications (Optional)
13+
APPRISE_URL= # Apprise URL for notifications (e.g., tgram://bottoken/ChatID)
14+
APPRISE_MESSAGE=New file uploaded - {filename} ({size}), Storage used {storage}
15+
APPRISE_SIZE_UNIT=auto # Size unit for notifications (auto, B, KB, MB, GB, TB)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ No auth (unless you want it now!), no storage, no nothing. Just a simple file up
3232
| APPRISE_URL | Apprise URL for notifications | None | No |
3333
| APPRISE_MESSAGE | Notification message template | New file uploaded {filename} ({size}), Storage used {storage} | No |
3434
| APPRISE_SIZE_UNIT| Size unit for notifications | Auto | No |
35+
| AUTO_UPLOAD | Enable automatic upload on file selection | false | No |
3536
| ALLOWED_EXTENSIONS| Comma-separated list of allowed file extensions | None | No |
3637

3738
## File Extension Filtering

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
name: Dumb Drop
21
services:
32
dumbdrop:
43
ports:
@@ -10,6 +9,8 @@ services:
109
MAX_FILE_SIZE: 1024
1110
DUMBDROP_PIN: 123456
1211
# APPRISE_URL: ntfys://
12+
# APPRISE_MESSAGE: New file uploaded - {filename} ({size}), Storage used {storage}
13+
# AUTO_UPLOAD: false
1314
APPRISE_MESSAGE: New file uploaded - {filename} ({size}), Storage used {storage}
1415
APPRISE_SIZE_UNIT: auto
1516
image: dumbwareio/dumbdrop:latest

public/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ <h1>{{SITE_TITLE}}</h1>
6060
const CHUNK_SIZE = 1024 * 1024; // 1MB chunks
6161
const MAX_RETRIES = 3;
6262
const RETRY_DELAY = 1000;
63+
const AUTO_UPLOAD = ['true', '1', 'yes'].includes('{{AUTO_UPLOAD}}'.toLowerCase());
6364

6465
// Utility function to generate a unique batch ID
6566
function generateBatchId() {
@@ -315,6 +316,7 @@ <h1>{{SITE_TITLE}}</h1>
315316
getAllFileEntries(items).then(newFiles => {
316317
files = newFiles;
317318
updateFileList();
319+
if (AUTO_UPLOAD) startUploads();
318320
});
319321
} else {
320322
// Handle single file drop
@@ -325,6 +327,7 @@ <h1>{{SITE_TITLE}}</h1>
325327
file.batchId = batchId;
326328
});
327329
updateFileList();
330+
if (AUTO_UPLOAD) startUploads();
328331
}
329332
}
330333

@@ -336,6 +339,7 @@ <h1>{{SITE_TITLE}}</h1>
336339
file.batchId = batchId;
337340
});
338341
updateFileList();
342+
if (AUTO_UPLOAD) startUploads();
339343
}
340344

341345
function handleFolders(e) {
@@ -348,6 +352,7 @@ <h1>{{SITE_TITLE}}</h1>
348352
file.batchId = batchId;
349353
});
350354
updateFileList();
355+
if (AUTO_UPLOAD) startUploads();
351356
}
352357

353358
function updateFileList() {
@@ -367,7 +372,7 @@ <h1>{{SITE_TITLE}}</h1>
367372
fileList.appendChild(fileItem);
368373
});
369374

370-
uploadButton.style.display = files.length > 0 ? 'block' : 'none';
375+
uploadButton.style.display = (!AUTO_UPLOAD && files.length > 0) ? 'block' : 'none';
371376
}
372377

373378
function formatFileSize(bytes) {

server.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ const port = process.env.PORT || 3000;
1818
const uploadDir = './uploads'; // Local development
1919
const maxFileSize = parseInt(process.env.MAX_FILE_SIZE || '1024') * 1024 * 1024; // Convert MB to bytes
2020
const APPRISE_URL = process.env.APPRISE_URL;
21-
const APPRISE_MESSAGE = process.env.APPRISE_MESSAGE || 'New file uploaded - {filename} ({size}), Storage used: {storage}';
21+
const APPRISE_MESSAGE = process.env.APPRISE_MESSAGE || 'New file uploaded - {filename} ({size}), Storage used {storage}';
2222
const siteTitle = process.env.DUMBDROP_TITLE || 'DumbDrop';
2323
const APPRISE_SIZE_UNIT = process.env.APPRISE_SIZE_UNIT;
24+
const AUTO_UPLOAD = process.env.AUTO_UPLOAD === 'true';
2425

2526
// Update the chunk size and rate limits
2627
const CHUNK_SIZE = 5 * 1024 * 1024; // Increase to 5MB chunks
@@ -238,7 +239,8 @@ app.get('/', (req, res) => {
238239
}
239240
// Read the file and replace the title
240241
let html = fs.readFileSync(path.join(__dirname, 'public', 'index.html'), 'utf8');
241-
html = html.replace(/{{SITE_TITLE}}/g, siteTitle); // Use global replace
242+
html = html.replace(/{{SITE_TITLE}}/g, siteTitle);
243+
html = html.replace('{{AUTO_UPLOAD}}', AUTO_UPLOAD.toString());
242244
res.send(html);
243245
});
244246

@@ -533,6 +535,9 @@ app.listen(port, () => {
533535
log.info(`Custom title set to: ${siteTitle}`);
534536
}
535537

538+
// Add auto upload status logging
539+
log.info(`Auto upload is ${AUTO_UPLOAD ? 'enabled' : 'disabled'}`);
540+
536541
// Add Apprise configuration logging
537542
if (APPRISE_URL) {
538543
log.info('Apprise notifications enabled');

0 commit comments

Comments
 (0)