Repository navigation
Description
Is your feature request related to a problem?
The upload page remembers the last values in the browser, but the starting point is always 1 download and 14 days. The same values are hardcoded on the server side, used when an API call doesn't include them.
So every new browser or new user starts from 1 / 14 again, and API clients always get 1 / 14 if they leave the values out. On my instance I almost always use different values (more downloads, shorter expiry, often a password), and it would be nice to set them once for the whole server.
Describe the solution you'd like
A few environment variables, like the existing GOKAPI_MAX_SIZE_GUESTUPLOAD:
GOKAPI_DEFAULT_DOWNLOADS(default 1, 0 for unlimited)GOKAPI_DEFAULT_EXPIRY_DAYS(default 14, 0 for no expiry)GOKAPI_DEFAULT_PASSWORD(default false): if true, the password switch on the upload page is already on. This one would only affect the web UI, the API has no use for it.
If they are not set, nothing changes.
The upload page would use them only when the browser has nothing saved yet, so the values remembered in the browser still win. The API would use them when allowedDownloads or expiryDays are missing.
For gokapi-cli it's a bit different: it always sends both values, 0 (unlimited) if the flags are not given, so it would never pick up the server defaults. My idea is to report the defaults in /info/config only when they are actually set, and in that case let the CLI leave the values out. Otherwise the CLI keeps working as it does now, so existing scripts are not affected.
Describe alternatives you've considered
I thought about adding the values to config.json, but that means changing the setup as well, and an environment variable seemed enough for something you set once. Per-user defaults would be nicer but need database changes. A default in the CLI config file would only help CLI users.
Additional Context
This is close to #265 and #440, but those are about limits, while this is only about the starting values. If #440 is merged, the default expiry should of course be capped to the maximum, like #440 already does for the 14 days. The CLI part would work the same way as in #440.
I'd be glad to work on a PR for this if you think it's a good idea. I saw that #440 and #405 touch some of the same files, so I can wait for them or rebase as needed.
Impact
- This would be a breaking change to existing setups.
Activity