improve dnd; prevent large files early on upload

This commit is contained in:
2026-11-21 19:28:44 -05:00
parent 67849def05
commit 8fc87ab200
8 changed files with 64 additions and 15 deletions
+13 -9
View File
@@ -22,11 +22,13 @@ type Pages struct {
}
type HomePageData struct {
Expiries []config.Expiry
Qt string
PastePlaceholder string
FileMaxSize string
PasteMaxSize string
Expiries []config.Expiry
Qt string
PastePlaceholder string
FileMaxSize string
FileMaxSizeBytes int64
PasteMaxSize string
PasteMaxSizeBytes int64
}
func (pages *Pages) Render(w http.ResponseWriter, name string, data any) {
@@ -108,10 +110,12 @@ func LoadPages() (*Pages, error) {
func HomeHandler(pages *Pages, cfg config.Config) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
data := HomePageData{
Expiries: cfg.Expiries,
FileMaxSize: humanize.Bytes(uint64(cfg.MaxFileBytes)),
PasteMaxSize: humanize.Bytes(uint64(cfg.MaxPasteBytes)),
Qt: GetRandomQt(pages.Qts),
Expiries: cfg.Expiries,
FileMaxSize: humanize.Bytes(uint64(cfg.MaxFileBytes)),
FileMaxSizeBytes: cfg.MaxFileBytes,
PasteMaxSize: humanize.Bytes(uint64(cfg.MaxPasteBytes)),
PasteMaxSizeBytes: cfg.MaxPasteBytes,
Qt: GetRandomQt(pages.Qts),
}
if len(pages.Placeholders) > 0 {