Compare commits
11 Commits
099d2ec6e9
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c8e42f1ef | |||
| 6090d8f596 | |||
| 205d62a634 | |||
| ecc96a3e28 | |||
| a0f2316d53 | |||
| d4159dcd9e | |||
| c340a75eda | |||
| 4cc360c3ca | |||
| f7cce5ceec | |||
| bc1cff21c5 | |||
| d48d51bdc3 |
14
.env.example
14
.env.example
@@ -9,10 +9,11 @@ TIMEZONE=America/Edmonton
|
||||
PUBLIC_UPLOAD_PAGE_ENABLED=true
|
||||
|
||||
# Local dedupe cache (SQLite)
|
||||
STATE_DB=./data/state.db
|
||||
#STATE_DB=./data/state.db
|
||||
|
||||
# Base URL for generating absolute invite links (recommended for production)
|
||||
# e.g., PUBLIC_BASE_URL=https://photos.example.com
|
||||
# Base URL for generating absolute invite links
|
||||
# Recommended for production, also sets CORS headers
|
||||
# e.g., PUBLIC_BASE_URL=https://upload.example.com
|
||||
#PUBLIC_BASE_URL=
|
||||
|
||||
LOG_LEVEL=INFO
|
||||
@@ -23,13 +24,12 @@ LOG_LEVEL=INFO
|
||||
CHUNKED_UPLOADS_ENABLED=true
|
||||
CHUNK_SIZE_MB=50
|
||||
|
||||
# Custom session secrets
|
||||
# By default, a random one is generated
|
||||
#SESSION_SECRET=SET-A-STRONG-RANDOM-VALUE
|
||||
|
||||
# Optional Telegram bot for upload alerts and control
|
||||
# create a bot using @BotFather then copy the API key here
|
||||
# get your account's ID by messaging https://t.me/userinfobot
|
||||
# Leave these blank to disable
|
||||
# Example:
|
||||
# TELEGRAM_BOT_API_KEY=1234567890:ABCDefghIjKlmnOPQRsT-UVWXyzABCdefGH
|
||||
# TELEGRAM_BOT_OWNER_ID=12345678
|
||||
TELEGRAM_BOT_API_KEY=
|
||||
TELEGRAM_BOT_OWNER_ID=
|
||||
|
||||
14
Dockerfile
14
Dockerfile
@@ -1,28 +1,22 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /image_drop
|
||||
WORKDIR /file_drop
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1
|
||||
|
||||
# Install Python deps
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt \
|
||||
&& pip install --no-cache-dir python-multipart
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy app code
|
||||
COPY . /image_drop
|
||||
|
||||
|
||||
# Data dir for SQLite (state.db)
|
||||
#RUN mkdir -p /data
|
||||
#VOLUME ["/data"]
|
||||
COPY . /file_drop
|
||||
|
||||
# Defaults (can be overridden via compose env)
|
||||
ENV HOST=0.0.0.0 \
|
||||
PORT=8080 \
|
||||
STATE_DB=/image_drop/data/state.db
|
||||
STATE_DB=/file_drop/data/state.db
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Simon Adams
|
||||
Copyright (c) 2025 Simon Adams, Tanner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
356
README.md
356
README.md
@@ -1,198 +1,164 @@
|
||||
# Immich Drop Uploader
|
||||
# File Drop Uploader
|
||||
|
||||
A tiny web app for collecting photos/videos into your **Immich** server.
|
||||
Admin users log in to create public invite links; invite links are always public-by-URL. A public uploader page is optional and disabled by default.
|
||||
A self-hosted web app for uploading files and media and saving them to the filesystem on your server.
|
||||
Useful for letting people upload vacation photos, etc. just by sending them a link.
|
||||
|
||||

|
||||
Admin user can create invite links with optional limits and password protection. A public uploader page is optional and enabled by default.
|
||||
|
||||
[View Screenshots](screenshots.md)
|
||||
|
||||
## Features
|
||||
|
||||
- **Invite Links:** public-by-URL links for uploads; one-time or multi-use
|
||||
- **Manage Links:** search/sort, enable/disable, delete, edit name/expiry
|
||||
- **Row Actions:** icon-only actions with tooltips (Open, Copy, Details, QR, Save)
|
||||
- **Passwords (optional):** protect invites with a password gate
|
||||
- **Albums (optional):** upload into a specific album (auto-create supported)
|
||||
- **Duplicate Prevention:** local SHA‑1 cache (+ optional Immich bulk-check)
|
||||
- **Progress Queue:** WebSocket updates; retry failed items
|
||||
- **Chunked Uploads (optional):** large-file support with configurable chunk size
|
||||
- **Privacy-first:** never lists server media; session-local uploads only
|
||||
- **Mobile + Dark Mode:** responsive UI, safe-area padding, persistent theme
|
||||
- **Local Saving:** All uploaded files are saved to the server's local filesystem.
|
||||
- **Drag and Drop:** Upload multiple files and folders by dragging them onto the page.
|
||||
- **Invite Links:** Create sharable links for uploads; one-time or multi-use.
|
||||
- **Manage Links:** Search/sort, enable/disable, delete, edit name/expiry.
|
||||
- **Passwords (optional):** Protect invite links with a password.
|
||||
- **Albums:** Upload into a specific folder (auto-create supported). Preserves client-side folder structure on upload.
|
||||
- **Duplicate Prevention:** Local SHA‑1 cache prevents re-uploading the same file.
|
||||
- **Telegram Notifications (optional):** Get notified via Telegram when upload batches are complete.
|
||||
- **Progress Queue:** WebSocket updates; see upload progress in real-time.
|
||||
- **Chunked Uploads (optional):** Large-file support with configurable chunk size.
|
||||
- **Mobile + Dark Mode:** Responsive UI, safe-area padding, persistent theme.
|
||||
|
||||
---
|
||||
|
||||
## Table of contents
|
||||
- [Quick start](#quick-start)
|
||||
- [New Features](#new-features)
|
||||
- [Chunked Uploads](#chunked-uploads)
|
||||
- [Architecture](#architecture)
|
||||
- [Folder structure](#folder-structure)
|
||||
- [Requirements](#requirements)
|
||||
- [Configuration (.env)](#configuration-env)
|
||||
- [How it works](#how-it-works)
|
||||
- [Mobile notes](#mobile-notes)
|
||||
- [Troubleshooting](#troubleshooting)
|
||||
- [Security notes](#security-notes)
|
||||
- [Development](#development)
|
||||
- [License](#license)
|
||||
|
||||
---
|
||||
## Quick start
|
||||
You can run without a `.env` file by putting all settings in `docker-compose.yml` (recommended for deploys).
|
||||
Use a `.env` file only for local development.
|
||||
|
||||
### docker-compose.yml (deploy without .env)
|
||||
Clone the repo.
|
||||
|
||||
Copy `.env.example` to `.env` and edit.
|
||||
|
||||
### Docker Compose
|
||||
|
||||
Create `docker-compose.yml` and edit:
|
||||
|
||||
```yaml
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
immich-drop:
|
||||
image: ghcr.io/nasogaa/immich-drop:latest
|
||||
pull_policy: always
|
||||
container_name: immich-drop
|
||||
file-drop:
|
||||
build: .
|
||||
container_name: file-drop
|
||||
restart: unless-stopped
|
||||
|
||||
# Configure all settings here (no .env required)
|
||||
environment:
|
||||
|
||||
# Immich connection (must include /api)
|
||||
IMMICH_BASE_URL: https://immich.example.com/api
|
||||
IMMICH_API_KEY: ${IMMICH_API_KEY}
|
||||
|
||||
# Optional behavior
|
||||
IMMICH_ALBUM_NAME: dead-drop
|
||||
PUBLIC_UPLOAD_PAGE_ENABLED: "false" # keep disabled by default
|
||||
PUBLIC_BASE_URL: https://drop.example.com
|
||||
|
||||
# Large files: chunked uploads (bypass 100MB proxy limits)
|
||||
CHUNKED_UPLOADS_ENABLED: "false" # enable chunked uploads
|
||||
CHUNK_SIZE_MB: "95" # per-chunk size (MB)
|
||||
|
||||
# App internals
|
||||
SESSION_SECRET: ${SESSION_SECRET}
|
||||
|
||||
# Expose the app on the host
|
||||
ports:
|
||||
- 8080:8080
|
||||
|
||||
# Persist local dedupe cache (state.db) across restarts
|
||||
- "8080:8080"
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- immich_drop_data:/data
|
||||
|
||||
# Simple healthcheck
|
||||
- ./data:/file_drop/data
|
||||
- /mnt/example/file-drop:/file_drop/data/uploads
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "python - <<'PY'\nimport os,urllib.request,sys; url=f\"http://127.0.0.1:{os.getenv('PORT','8080')}/\";\ntry: urllib.request.urlopen(url, timeout=3); sys.exit(0)\nexcept Exception: sys.exit(1)\nPY"]
|
||||
test: ["CMD-SHELL", "python - <<'PY'\nimport urllib.request,sys\ntry:\n urllib.request.urlopen('http://localhost:8080/').read(); sys.exit(0)\nexcept Exception:\n sys.exit(1)\nPY"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
volumes:
|
||||
immich_drop_data:
|
||||
```
|
||||
|
||||
```
|
||||
### CLI
|
||||
Start the service:
|
||||
|
||||
```bash
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
$ sudo docker compose up --build -d
|
||||
```
|
||||
---
|
||||
|
||||
## What's New
|
||||
Set up nginx / a reverse proxy and point it to the web app.
|
||||
|
||||
### v0.5.0 – Manage Links overhaul
|
||||
- In-panel bulk actions footer (Delete/Enable/Disable stay inside the box)
|
||||
- Per-row icon actions with tooltips; Save button lights up only on changes
|
||||
- Per-row QR modal; Details modal close fixed and reliable
|
||||
- Auto-refresh after creating a link; new row is highlighted and scrolled into view
|
||||
- Expiry save fix: stores end-of-day to avoid off-by-one date issues
|
||||
Make sure it allows WebSocket connections through, for example:
|
||||
|
||||
Roadmap highlight
|
||||
- We’d like to add a per-user UI and remove reliance on a fixed API key by allowing users to authenticate and provide their own Immich API tokens. This is not in scope for the initial versions but aligns with future direction.
|
||||
- The frontend automatically switches to chunked mode only for files larger than the configured chunk size.
|
||||
```
|
||||
server {
|
||||
root /var/www/html;
|
||||
index index.html index.htm;
|
||||
server_name upload.example.com;
|
||||
|
||||
### 📱 Device‑Flexible HMI (New)
|
||||
- Fully responsive UI with improved spacing and wrapping for small and large screens.
|
||||
- Mobile‑safe file picker and a sticky bottom “Choose files” bar on phones.
|
||||
- Safe‑area padding for devices with notches; refined dark/light theme behavior.
|
||||
- Desktop keeps the dropzone clickable; touch devices avoid accidental double‑open.
|
||||
listen 80;
|
||||
|
||||
### ♻️ Reliability & Quality of Life (New)
|
||||
- Retry button to re‑attempt any failed upload without re‑selecting the file.
|
||||
- Progress and status updates are more resilient to late/reordered WebSocket events.
|
||||
- Invites can be created without an album, keeping uploads unassigned when preferred.
|
||||
client_max_body_size 100M;
|
||||
|
||||
### Last 8 Days – Highlights
|
||||
- Added chunked uploads with configurable chunk size.
|
||||
- Added optional passwords for invite links with in‑UI unlock prompt.
|
||||
- Responsive HMI overhaul: mobile‑safe picker, sticky mobile action bar, safe‑area support.
|
||||
- Retry for failed uploads and improved progress handling.
|
||||
- Support for invites with no album association.
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8080/;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
### 🌙 Dark Mode
|
||||
- Automatic or manual toggle; persisted preference
|
||||
# websockets
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_redirect off;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 📁 Album Integration
|
||||
- Auto-create + assign album if configured; optional invites without album
|
||||
Then restart nginx and set up HTTPS:
|
||||
|
||||
---
|
||||
```
|
||||
$ sudo service nginx restart
|
||||
$ sudo certbot --nginx
|
||||
```
|
||||
|
||||
## Chunked Uploads
|
||||
|
||||
- Enable chunked uploads by setting `CHUNKED_UPLOADS_ENABLED=true`.
|
||||
- Configure chunk size with `CHUNK_SIZE_MB` (default: `95`). The client only uses chunked mode for files larger than this.
|
||||
- Intended to bypass upstream limits (e.g., 100MB) while preserving duplicate checks, EXIF timestamps, album add, and per‑item progress via WebSocket.
|
||||
### Config Changes
|
||||
|
||||
---
|
||||
If you change the `.env` file config, simply run:
|
||||
|
||||
## Architecture
|
||||
```bash
|
||||
$ sudo docker compose down
|
||||
$ sudo docker compose up --build -d
|
||||
```
|
||||
|
||||
### Updating
|
||||
|
||||
To update the code:
|
||||
|
||||
```bash
|
||||
$ sudo docker compose down
|
||||
$ git pull --rebase
|
||||
$ sudo docker compose up --build -d
|
||||
```
|
||||
|
||||
### Telegram Bot
|
||||
|
||||
An optional Telegram bot can send you notifications when uploads complete. This is useful to see if random people are filling your disk up.
|
||||
|
||||
To create a bot, message @BotFather on Telegram. Come up with a name and username. Botfather will then send you an API key you can paste into the `.env` config directly.
|
||||
|
||||
Next you'll need to find your own Telegram user ID. You can message @userinfobot and it will reply with your ID. Beware of impersonator bots (they have the name "userinfobot" but a different username).
|
||||
|
||||
Then message the bot you just created "/start" so that it's able to interact with you.
|
||||
|
||||
|
||||
### Chunked Uploads
|
||||
|
||||
- Chunked uploads are enabled by default. Uses setting `CHUNKED_UPLOADS_ENABLED=true`.
|
||||
- Configure chunk size with `CHUNK_SIZE_MB` (default: `50`). The client only uses chunked mode for files larger than this.
|
||||
- Intended to bypass upstream proxy limits (e.g., 100MB) while preserving duplicate checks, EXIF timestamps, album add, and per‑item progress via WebSocket.
|
||||
|
||||
## Development
|
||||
|
||||
### Architecture
|
||||
|
||||
- **Frontend:** static HTML/JS (Tailwind). Drag & drop or "Choose files", queue UI with progress and status chips.
|
||||
- **Backend:** FastAPI + Uvicorn.
|
||||
- Proxies uploads to Immich `/assets`
|
||||
- Computes SHA‑1 and checks a local SQLite cache (`state.db`)
|
||||
- Optional Immich de‑dupe via `/assets/bulk-upload-check`
|
||||
- WebSocket `/ws` pushes per‑item progress to the current browser session only
|
||||
- **Persistence:** local SQLite (`state.db`) prevents re‑uploads across sessions/runs.
|
||||
- Saves uploaded files to the local filesystem.
|
||||
- Computes SHA‑1 and checks a local SQLite cache (`state.db`) to prevent duplicates.
|
||||
- WebSocket `/ws` pushes per‑item progress to the current browser session only.
|
||||
- **Persistence:** A local SQLite database (`state.db`) prevents re‑uploads across sessions. Uploaded files are stored in `/data/uploads`.
|
||||
|
||||
---
|
||||
### Setup
|
||||
|
||||
## Folder structure
|
||||
Requires Python 3.11+.
|
||||
|
||||
```
|
||||
immich_drop/
|
||||
├─ app/ # FastAPI application (Python package)
|
||||
│ ├─ app.py # ASGI app (uvicorn entry: app.app:app)
|
||||
│ └─ config.py # Settings loader (reads .env/env)
|
||||
├─ frontend/ # Static UI (served at /static)
|
||||
│ ├─ index.html # Public uploader (optional)
|
||||
│ ├─ login.html # Login page (admin)
|
||||
│ ├─ menu.html # Admin menu (create invites)
|
||||
│ ├─ invite.html # Public invite upload page
|
||||
│ ├─ app.js # Uploader logic (drop/queue/upload/ws)
|
||||
│ ├─ header.js # Shared header (theme + ping + banner)
|
||||
│ └─ favicon.png # Tab icon (optional)
|
||||
├─ data/ # Local dev data dir (bind to /data in Docker)
|
||||
├─ main.py # Thin dev entrypoint (python main.py)
|
||||
├─ requirements.txt # Python dependencies
|
||||
├─ Dockerfile
|
||||
├─ docker-compose.yml
|
||||
├─ .env.example # Example dev environment (optional)
|
||||
├─ README.md
|
||||
└─ screenshot.png # UI screenshot for README
|
||||
Create a venv, activate it, and install:
|
||||
|
||||
```text
|
||||
$ virtualenv -p python3 env
|
||||
$ source env/bin/activate
|
||||
(env) $ pip install -r requirements.txt
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Requirements
|
||||
|
||||
- **Python** 3.11
|
||||
- An **Immich** server + **API key**
|
||||
|
||||
---
|
||||
# Local dev quickstart
|
||||
|
||||
## Development
|
||||
```text
|
||||
(env) $ cp .env.example .env
|
||||
(env) $ vim .env
|
||||
```
|
||||
|
||||
Run with live reload:
|
||||
|
||||
@@ -200,82 +166,30 @@ Run with live reload:
|
||||
python main.py
|
||||
```
|
||||
|
||||
The backend contains docstrings so you can generate docs later if desired.
|
||||
### How it works
|
||||
|
||||
---
|
||||
1. **Queue** - Files selected in the browser are queued; each gets a client-side ID.
|
||||
2. **De-dupe (local)** - Server computes **SHA‑1** and checks `state.db`. If seen, marks as **duplicate**.
|
||||
3. **Save** - The file is saved to the local filesystem under `./data/uploads`.
|
||||
4. **Album** - If an album is specified via an invite link, or a folder name is provided on the public page, the file is saved into a corresponding subdirectory. Client-side folder structure is also preserved.
|
||||
5. **Progress** - Backend streams progress via WebSocket to the same session.
|
||||
6. **Privacy** - The UI shows only the current session's items. It does not provide a way to browse saved files.
|
||||
|
||||
## Dev Configuration (.env)
|
||||
|
||||
```ini
|
||||
# Server (dev only)
|
||||
HOST=0.0.0.0
|
||||
PORT=8080
|
||||
|
||||
# Immich connection (include /api)
|
||||
IMMICH_BASE_URL=http://REPLACE_ME:2283/api
|
||||
IMMICH_API_KEY=ADD-YOUR-API-KEY # needs: asset.upload; for albums also: album.create, album.read, albumAsset.create
|
||||
MAX_CONCURRENT=3
|
||||
|
||||
# Public uploader page (optional) — disabled by default
|
||||
PUBLIC_UPLOAD_PAGE_ENABLED=TRUE
|
||||
|
||||
# Album (optional): auto-add uploads from public uploader to this album (creates if needed)
|
||||
IMMICH_ALBUM_NAME=dead-drop
|
||||
|
||||
# Local dedupe cache (SQLite)
|
||||
STATE_DB=./data/state.db
|
||||
|
||||
# Base URL for generating absolute invite links (recommended for production)
|
||||
# e.g., PUBLIC_BASE_URL=https://photos.example.com
|
||||
#PUBLIC_BASE_URL=
|
||||
|
||||
# Session and security
|
||||
SESSION_SECRET=SET-A-STRONG-RANDOM-VALUE
|
||||
LOG_LEVEL=DEBUG
|
||||
|
||||
# Chunked uploads (optional)
|
||||
CHUNKED_UPLOADS_ENABLED=true
|
||||
CHUNK_SIZE_MB=95
|
||||
|
||||
```
|
||||
|
||||
|
||||
You can keep a checked‑in `/.env.example` with the keys above for onboarding.
|
||||
|
||||
---
|
||||
|
||||
## How it works
|
||||
|
||||
1. **Queue** – Files selected in the browser are queued; each gets a client‑side ID.
|
||||
2. **De‑dupe (local)** – Server computes **SHA‑1** and checks `state.db`. If seen, marks as **duplicate**.
|
||||
3. **De‑dupe (server)** – Attempts Immich `/assets/bulk-upload-check`; if Immich reports duplicate, marks accordingly.
|
||||
4. **Upload** – Multipart POST to `${IMMICH_BASE_URL}/assets` with:
|
||||
- `assetData`, `deviceAssetId`, `deviceId`,
|
||||
- `fileCreatedAt`, `fileModifiedAt` (from EXIF when available; else `lastModified`),
|
||||
- `isFavorite=false`, `filename`, and header `x-immich-checksum`.
|
||||
5. **Album** – If `IMMICH_ALBUM_NAME` is configured, adds the uploaded asset to the album (creates album if it doesn't exist).
|
||||
6. **Progress** – Backend streams progress via WebSocket to the same session.
|
||||
7. **Privacy** – UI shows only the current session's items. It never lists server media.
|
||||
|
||||
---
|
||||
|
||||
## Security notes
|
||||
### Security notes
|
||||
|
||||
- The menu and invite creation are behind login. Logout clears the session.
|
||||
- Invite links are public by URL; share only with intended recipients.
|
||||
- The default uploader page at `/` is disabled unless `PUBLIC_UPLOAD_PAGE_ENABLED=true`.
|
||||
- The Immich API key remains **server‑side**; the browser never sees it.
|
||||
- The public uploader page at `/` is enabled unless disabled with `PUBLIC_UPLOAD_PAGE_ENABLED=false`.
|
||||
- No browsing of uploaded media; only ephemeral session state is shown.
|
||||
- Run behind HTTPS with a reverse proxy and restrict CORS to your domain(s).
|
||||
|
||||
## Usage flow
|
||||
|
||||
- Admin: Login → Menu → Create invite link (optionally one‑time / expiry / album) → Share link or QR.
|
||||
- Guest: Open invite link → Drop files → Upload progress and results shown.
|
||||
- Optional: Enable public uploader and set `IMMICH_ALBUM_NAME` for a default landing page.
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
MIT.
|
||||
This program is free and open-source software licensed under the MIT License. Please see the `LICENSE` file for details.
|
||||
|
||||
That means you have the right to study, change, and distribute the software and source code to anyone and for any purpose. You deserve these rights.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
This project was forked from "Immich Drop Uploader" by Simon Adams: https://github.com/Nasogaa/immich-drop
|
||||
|
||||
|
||||
27
app/app.py
27
app/app.py
@@ -41,16 +41,20 @@ from app.config import Settings, load_settings
|
||||
|
||||
# ---- App & static ----
|
||||
app = FastAPI(title="Immich Drop Uploader (Python)")
|
||||
# Global settings (read-only at runtime)
|
||||
SETTINGS: Settings = load_settings()
|
||||
|
||||
# CORS
|
||||
origins = ["*"]
|
||||
if SETTINGS.public_base_url:
|
||||
origins = [SETTINGS.public_base_url.strip().rstrip('/')]
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_origins=origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# Global settings (read-only at runtime)
|
||||
SETTINGS: Settings = load_settings()
|
||||
_public_uploads_enabled_runtime = SETTINGS.public_upload_page_enabled
|
||||
|
||||
|
||||
@@ -235,7 +239,7 @@ def _schedule_batch_notification():
|
||||
asyncio.create_task(send_batch_notification())
|
||||
|
||||
async def reset_telegram_debounce():
|
||||
"""Resets the 30s timer for batch completion notification."""
|
||||
"""Resets the 120s timer for batch completion notification."""
|
||||
if not SETTINGS.telegram_bot_api_key or not TELEGRAM_OWNER_ID:
|
||||
return
|
||||
|
||||
@@ -244,7 +248,7 @@ async def reset_telegram_debounce():
|
||||
if _batch_complete_timer:
|
||||
_batch_complete_timer.cancel()
|
||||
loop = asyncio.get_event_loop()
|
||||
_batch_complete_timer = loop.call_later(10, _schedule_batch_notification)
|
||||
_batch_complete_timer = loop.call_later(120, _schedule_batch_notification)
|
||||
|
||||
async def add_file_to_batch(filename: str, size: int, album_name: str, is_invite: bool):
|
||||
"""Adds a completed file to the batch list."""
|
||||
@@ -1127,6 +1131,17 @@ async def api_upload_chunk_complete(request: Request) -> JSONResponse:
|
||||
await send_progress(session_id_local, item_id_local, "error", 100, "Failed to save file locally")
|
||||
return JSONResponse({"error": "local_save_failed"}, status_code=500)
|
||||
|
||||
@app.post("/api/uploads/batch_complete_hint")
|
||||
async def api_batch_complete_hint(request: Request) -> JSONResponse:
|
||||
"""
|
||||
Client-side hint that a batch of uploads has completed.
|
||||
This triggers the batch notification immediately instead of waiting for the debounce timer.
|
||||
"""
|
||||
# session_id from body is optional, for future use, but not currently used
|
||||
# because the batch is global.
|
||||
await send_batch_notification()
|
||||
return JSONResponse({"ok": True})
|
||||
|
||||
|
||||
# ---------- Auth & Albums & Invites APIs ----------
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@ class Settings:
|
||||
"""App settings loaded from environment variables (.env)."""
|
||||
admin_password: str
|
||||
max_concurrent: int
|
||||
public_upload_page_enabled: bool = False
|
||||
public_upload_page_enabled: bool = True
|
||||
public_base_url: str = ""
|
||||
state_db: str = ""
|
||||
session_secret: str = ""
|
||||
log_level: str = "INFO"
|
||||
chunked_uploads_enabled: bool = False
|
||||
chunk_size_mb: int = 95
|
||||
chunked_uploads_enabled: bool = True
|
||||
chunk_size_mb: int = 50
|
||||
timezone: str = "UTC"
|
||||
telegram_bot_api_key: str = ""
|
||||
telegram_bot_owner_id: str = ""
|
||||
@@ -48,7 +48,8 @@ def load_settings() -> Settings:
|
||||
load_dotenv()
|
||||
except Exception:
|
||||
pass
|
||||
admin_password = os.getenv("ADMIN_PASSWORD", "admin") # Default for convenience, should be changed
|
||||
|
||||
admin_password = os.getenv("ADMIN_PASSWORD", "test123") # Default for convenience, should be changed
|
||||
if not admin_password.startswith("pbkdf2_sha256-"):
|
||||
print("="*60)
|
||||
print("WARNING: ADMIN_PASSWORD is in plaintext.")
|
||||
@@ -57,27 +58,34 @@ def load_settings() -> Settings:
|
||||
if hashed_pw:
|
||||
print(f"ADMIN_PASSWORD={hashed_pw}")
|
||||
print("="*60)
|
||||
# Safe defaults: disable public uploader and invites unless explicitly enabled
|
||||
|
||||
def as_bool(v: str, default: bool = False) -> bool:
|
||||
if v is None:
|
||||
return default
|
||||
return str(v).strip().lower() in {"1","true","yes","on"}
|
||||
public_upload = as_bool(os.getenv("PUBLIC_UPLOAD_PAGE_ENABLED", "false"), False)
|
||||
|
||||
public_upload = as_bool(os.getenv("PUBLIC_UPLOAD_PAGE_ENABLED", "false"), True)
|
||||
|
||||
try:
|
||||
maxc = int(os.getenv("MAX_CONCURRENT", "3"))
|
||||
except ValueError:
|
||||
maxc = 3
|
||||
state_db = os.getenv("STATE_DB", "/data/state.db")
|
||||
|
||||
state_db = os.getenv("STATE_DB", "./data/state.db")
|
||||
session_secret = os.getenv("SESSION_SECRET") or secrets.token_hex(32)
|
||||
log_level = os.getenv("LOG_LEVEL", "INFO").upper()
|
||||
chunked_uploads_enabled = as_bool(os.getenv("CHUNKED_UPLOADS_ENABLED", "false"), False)
|
||||
|
||||
chunked_uploads_enabled = as_bool(os.getenv("CHUNKED_UPLOADS_ENABLED", "false"), True)
|
||||
try:
|
||||
chunk_size_mb = int(os.getenv("CHUNK_SIZE_MB", "95"))
|
||||
chunk_size_mb = int(os.getenv("CHUNK_SIZE_MB", "50"))
|
||||
except ValueError:
|
||||
chunk_size_mb = 95
|
||||
chunk_size_mb = 50
|
||||
|
||||
timezone = os.getenv("TIMEZONE", "UTC")
|
||||
|
||||
telegram_bot_api_key = os.getenv("TELEGRAM_BOT_API_KEY", "")
|
||||
telegram_bot_owner_id = os.getenv("TELEGRAM_BOT_OWNER_ID", "")
|
||||
|
||||
return Settings(
|
||||
admin_password=admin_password,
|
||||
max_concurrent=maxc,
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
services:
|
||||
image-drop:
|
||||
build: .
|
||||
container_name: image-drop
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:8080"
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- ./data:/image_drop/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "python - <<'PY'\nimport urllib.request,sys\ntry:\n urllib.request.urlopen('http://localhost:8080/').read(); sys.exit(0)\nexcept Exception:\n sys.exit(1)\nPY"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
@@ -1,33 +0,0 @@
|
||||
services:
|
||||
immich-drop:
|
||||
build: .
|
||||
container_name: immich-drop
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:8080"
|
||||
|
||||
environment:
|
||||
#immich drop server ip
|
||||
IMMICH_BASE_URL: https://immich.example.com/api
|
||||
IMMICH_API_KEY: ${IMMICH_API_KEY}
|
||||
|
||||
PUBLIC_BASE_URL: https://drop.example.com
|
||||
#Enable/Disable Public upload page to folder
|
||||
PUBLIC_UPLOAD_PAGE_ENABLED: false
|
||||
IMMICH_ALBUM_NAME: dead-drop
|
||||
# Chunked uploads to bypass 100MB limits (e.g., Cloudflare Tunnel)
|
||||
CHUNKED_UPLOADS_ENABLED: true
|
||||
CHUNK_SIZE_MB: 95
|
||||
|
||||
|
||||
volumes:
|
||||
- immich_drop_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "python - <<'PY'\nimport urllib.request,sys\ntry:\n urllib.request.urlopen('http://localhost:8080/').read(); sys.exit(0)\nexcept Exception:\n sys.exit(1)\nPY"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
volumes:
|
||||
immich_drop_data:
|
||||
@@ -34,6 +34,7 @@ try {
|
||||
} catch {}
|
||||
let items = [];
|
||||
let socket;
|
||||
let allCompleteBannerShown = false;
|
||||
|
||||
// Status precedence: never regress (e.g., uploading -> done shouldn't go back to uploading)
|
||||
const STATUS_ORDER = { queued: 0, checking: 1, uploading: 2, duplicate: 3, done: 3, error: 4 };
|
||||
@@ -92,6 +93,7 @@ function addItem(file, relativePath){
|
||||
const resolvedPath = (relativePath !== undefined) ? relativePath : (file.webkitRelativePath || '');
|
||||
const it = { id, file, name: file.name, size: file.size, status: 'queued', progress: 0, relativePath: resolvedPath };
|
||||
items.unshift(it);
|
||||
allCompleteBannerShown = false;
|
||||
render();
|
||||
}
|
||||
|
||||
@@ -155,6 +157,19 @@ function render(){
|
||||
document.getElementById('countDone').textContent=c.done;
|
||||
document.getElementById('countDup').textContent=c.dup;
|
||||
document.getElementById('countErr').textContent=c.err;
|
||||
|
||||
if (!allCompleteBannerShown && items.length > 0) {
|
||||
const isComplete = items.every(it => FINAL_STATES.has(it.status));
|
||||
const hasSuccess = items.some(it => it.status === 'done');
|
||||
if (isComplete && hasSuccess) {
|
||||
showBanner("All uploads complete.", "ok");
|
||||
allCompleteBannerShown = true;
|
||||
// Hint to backend that this batch is done, to trigger notification sooner
|
||||
try {
|
||||
fetch('/api/uploads/batch_complete_hint', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ session_id: sessionId }) }).catch(()=>{});
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- WebSocket progress ---
|
||||
|
||||
BIN
media/admin-page.png
Normal file
BIN
media/admin-page.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 116 KiB |
BIN
media/after-uploading.png
Normal file
BIN
media/after-uploading.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
BIN
media/invite-page.png
Normal file
BIN
media/invite-page.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
BIN
media/public-uploader.png
Normal file
BIN
media/public-uploader.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
BIN
media/telegram-bot.png
Normal file
BIN
media/telegram-bot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 160 KiB |
21
screenshots.md
Normal file
21
screenshots.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Screenshots
|
||||
|
||||
## Public upload page
|
||||
|
||||

|
||||
|
||||
## After uploading files
|
||||
|
||||

|
||||
|
||||
## Admin page
|
||||
|
||||

|
||||
|
||||
## Invite link (with password)
|
||||
|
||||

|
||||
|
||||
## Telegram bot
|
||||
|
||||

|
||||
Reference in New Issue
Block a user