Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
8000 feat(webserver): Add public image URL system with token-based access by InterN0te · Pull Request #1125 · roflcoopter/viseron · GitHub
Nothing Special   »   [go: up one dir, main page]

Skip to content

Conversation

InterN0te
Copy link
Contributor
@InterN0te InterN0te commented Oct 13, 2025

Summary

This introduces a reusable system for serving images publicly without authentication, useful for external notification services like Gotify, Discord, or Telegram.

Features

  • ✅ Token-based public image access via /api/v1/publicimage endpoint
  • ✅ No authentication required for accessing images with valid tokens
  • ✅ Configurable expiration time (default: 24 hours, max: 31 days)
  • ✅ Persistent storage in /config/public_images/ (survives restarts)
  • ✅ Automatic cleanup of expired images (periodic + on startup)
  • ✅ Validates file existence even if token not in memory (handles restarts)

Configuration Options

webserver:
  public_base_url: "https://viseron.example.com"
  public_url_expiry_hours: 48  # default: 24, max: 744 (31 days)

Technical Details

  • Images stored with UUID token as filename
  • Tokens stored in memory with expiration timestamp
  • After restart, API falls back to disk lookup if token not in memory
  • Hourly cleanup task removes expired tokens and files
  • Startup cleanup removes orphaned files older than max expiry
  • Supports JPG and PNG formats

Use Cases

This system can be used by any notification component that needs to share images externally:

  • Gotify notifications
  • Discord webhooks
  • Telegram bots
  • Email notifications
  • Custom integrations

Testing

After merge, other components can use this system by:

  1. Saving image to `/config/public_images/{token}.jpg`
  2. Creating a `PublicImageToken` with expiration
  3. Storing it in `vis.data[PUBLIC_IMAGE_TOKENS]`
  4. Generating URL: `{public_base_url}/api/v1/publicimage?token={token}`

Breaking Changes

None - this is a new feature with no impact on existing functionality.

This introduces a reusable system for serving images publicly without authentication, useful for external notification services like Gotify, Discord, or Telegram.

Features:
- Token-based public image access via /api/v1/publicimage endpoint
- No authentication required for accessing images with valid tokens
- Configurable expiration time (default: 24 hours, max: 31 days)
- Persistent storage in /config/public_images/ (survives restarts)
- Automatic cleanup of expired images (periodic + on startup)
- Validates file existence even if token not in memory (handles restarts)

Configuration options:
- public_base_url: External URL for Viseron (e.g., https://viseron.example.com)
- public_url_expiry_hours: How long public URLs remain valid (default: 24)

Technical details:
- Images stored with UUID token as filename
- Tokens stored in memory with expiration timestamp
- After restart, API falls back to disk lookup if token not in memory
- Hourly cleanup task removes expired tokens and files
- Startup cleanup removes orphaned files older than max expiry
- Supports JPG and PNG formats

Example usage:
```yaml
webserver:
  public_base_url: "https://viseron.example.com"
  public_url_expiry_hours: 48
```
Copy link
netlify bot commented Oct 13, 2025

Deploy Preview for viseron ready!

Name Link
🔨 Latest commit b82e085
🔍 Latest deploy log https://app.netlify.com/projects/viseron/deploys/68f421aa75af7400084ad295
😎 Deploy Preview https://deploy-preview-1125--viseron.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

InterN0te and others added 5 commits October 13, 2025 21:08
- Remove unused datetime import in publicimage.py
- Fix type annotation for _cleanup_task (asyncio.Task | None)
- Simplify cleanup task cancellation to avoid unreachable code
- Break long log messages to stay within 88 character limit
- Use %s formatting instead of f-strings for long messages
- Shorten comments while preserving meaning
Add documentation for the new public_base_url and public_url_expiry_hours configuration options that enable public image URL generation with token-based access.
The cleanup of expired public images was incorrectly using utcnow()
which could cause premature deletion when the system timezone differs
from UTC. Changed to use current system time for file mtime comparisons.

Also simplified the cleanup logic to be file-based rather than
token-based, making it more robust across restarts.
@InterN0te InterN0te changed the title feat(webserver): Add public image URL system with token-based access [WIP] feat(webserver): Add public image URL system with token-based access Oct 18, 2025
@InterN0te
Copy link
Contributor Author

I will add one last parameter to allow the image to be retrieved multiple times instead of deleting it after the first retrieve

Add configurable download limit for public image tokens to automatically
delete images after a specified number of downloads.

Changes:
- Add remaining_downloads field to PublicImageToken dataclass
- Implement download counter decrement in publicimage API
- Add automatic cleanup after final download
- Add public_url_max_downloads configuration parameter (default: 0 = unlimited)
- Update webserver documentation with usage examples

Configuration:
- 0 (default): Unlimited downloads
- 1: Single-use URL (perfect for notifications)
- N > 1: Limited sharing (delete after N downloads)
@InterN0te InterN0te changed the title [WIP] feat(webserver): Add public image URL system with token-based access feat(webserver): Add public image URL system with token-based access Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0