-
-
Notifications
You must be signed in to change notification settings - Fork 266
feat(webserver): Add public image URL system with token-based access #1125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
InterN0te
wants to merge
7
commits into
roflcoopter:dev
Choose a base branch
from
InterN0te:feature/public-image-url-system
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(webserver): Add public image URL system with token-based access #1125
InterN0te
wants to merge
7
commits into
roflcoopter:dev
from
InterN0te:feature/public-image-url-system
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ```
✅ Deploy Preview for viseron ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- 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.
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)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This introduces a reusable system for serving images publicly without authentication, useful for external notification services like Gotify, Discord, or Telegram.
Features
/api/v1/publicimage
endpoint/config/public_images/
(survives restarts)Configuration Options
Technical Details
Use Cases
This system can be used by any notification component that needs to share images externally:
Testing
After merge, other components can use this system by:
Breaking Changes
None - this is a new feature with no impact on existing functionality.