Skip to content

Commit

Permalink
Merge pull request #21 from greirson/even-dumber-drop
Browse files Browse the repository at this point in the history
feat: Add auto upload configuration and update environment settings
  • Loading branch information
abiteman authored Feb 4, 2025
2 parents 432cf7e + 1644749 commit 3d10957
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
17 changes: 9 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Server Configuration
PORT=3000 # The port the server will listen on
DUMBDROP_TITLE=DumbDrop # Site title displayed in header (default: DumbDrop)

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

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

# Notifications
APPRISE_URL= # Apprise URL for notifications (leave empty to disable)
APPRISE_MESSAGE= # Custom message for notifications (default: "New file uploaded: {filename} ({size}), Storage used: {storage}")
APPRISE_SIZE_UNIT= # Size unit for notifications (B, KB, MB, GB, TB). Leave empty for auto
# Notifications (Optional)
APPRISE_URL= # Apprise URL for notifications (e.g., tgram://bottoken/ChatID)
APPRISE_MESSAGE=New file uploaded - {filename} ({size}), Storage used {storage}
APPRISE_SIZE_UNIT=auto # Size unit for notifications (auto, B, KB, MB, GB, TB)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ No auth (unless you want it now!), no storage, no nothing. Just a simple file up
| APPRISE_URL | Apprise URL for notifications | None | No |
| APPRISE_MESSAGE | Notification message template | New file uploaded {filename} ({size}), Storage used {storage} | No |
| APPRISE_SIZE_UNIT| Size unit for notifications | Auto | No |
| AUTO_UPLOAD | Enable automatic upload on file selection | false | No |
| ALLOWED_EXTENSIONS| Comma-separated list of allowed file extensions | None | No |

## File Extension Filtering
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
name: Dumb Drop
services:
dumbdrop:
ports:
Expand All @@ -10,6 +9,8 @@ services:
MAX_FILE_SIZE: 1024
DUMBDROP_PIN: 123456
# APPRISE_URL: ntfys://
# APPRISE_MESSAGE: New file uploaded - {filename} ({size}), Storage used {storage}
# AUTO_UPLOAD: false
APPRISE_MESSAGE: New file uploaded - {filename} ({size}), Storage used {storage}
APPRISE_SIZE_UNIT: auto
image: dumbwareio/dumbdrop:latest
Expand Down
7 changes: 6 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ <h1>{{SITE_TITLE}}</h1>
const CHUNK_SIZE = 1024 * 1024; // 1MB chunks
const MAX_RETRIES = 3;
const RETRY_DELAY = 1000;
const AUTO_UPLOAD = ['true', '1', 'yes'].includes('{{AUTO_UPLOAD}}'.toLowerCase());

// Utility function to generate a unique batch ID
function generateBatchId() {
Expand Down Expand Up @@ -315,6 +316,7 @@ <h1>{{SITE_TITLE}}</h1>
getAllFileEntries(items).then(newFiles => {
files = newFiles;
updateFileList();
if (AUTO_UPLOAD) startUploads();
});
} else {
// Handle single file drop
Expand All @@ -325,6 +327,7 @@ <h1>{{SITE_TITLE}}</h1>
file.batchId = batchId;
});
updateFileList();
if (AUTO_UPLOAD) startUploads();
}
}

Expand All @@ -336,6 +339,7 @@ <h1>{{SITE_TITLE}}</h1>
file.batchId = batchId;
});
updateFileList();
if (AUTO_UPLOAD) startUploads();
}

function handleFolders(e) {
Expand All @@ -348,6 +352,7 @@ <h1>{{SITE_TITLE}}</h1>
file.batchId = batchId;
});
updateFileList();
if (AUTO_UPLOAD) startUploads();
}

function updateFileList() {
Expand All @@ -367,7 +372,7 @@ <h1>{{SITE_TITLE}}</h1>
fileList.appendChild(fileItem);
});

uploadButton.style.display = files.length > 0 ? 'block' : 'none';
uploadButton.style.display = (!AUTO_UPLOAD && files.length > 0) ? 'block' : 'none';
}

function formatFileSize(bytes) {
Expand Down
9 changes: 7 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ const port = process.env.PORT || 3000;
const uploadDir = './uploads'; // Local development
const maxFileSize = parseInt(process.env.MAX_FILE_SIZE || '1024') * 1024 * 1024; // Convert MB to bytes
const APPRISE_URL = process.env.APPRISE_URL;
const APPRISE_MESSAGE = process.env.APPRISE_MESSAGE || 'New file uploaded - {filename} ({size}), Storage used: {storage}';
const APPRISE_MESSAGE = process.env.APPRISE_MESSAGE || 'New file uploaded - {filename} ({size}), Storage used {storage}';
const siteTitle = process.env.DUMBDROP_TITLE || 'DumbDrop';
const APPRISE_SIZE_UNIT = process.env.APPRISE_SIZE_UNIT;
const AUTO_UPLOAD = process.env.AUTO_UPLOAD === 'true';

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

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

// Add auto upload status logging
log.info(`Auto upload is ${AUTO_UPLOAD ? 'enabled' : 'disabled'}`);

// Add Apprise configuration logging
if (APPRISE_URL) {
log.info('Apprise notifications enabled');
Expand Down

0 comments on commit 3d10957

Please sign in to comment.