diff --git a/web/fup/fuphttp/fuphttp.go b/web/fup/fuphttp/fuphttp.go index b99f28b626..9405e6e995 100644 --- a/web/fup/fuphttp/fuphttp.go +++ b/web/fup/fuphttp/fuphttp.go @@ -18,6 +18,7 @@ import ( shuncheckedconversions "github.com/google/safehtml/uncheckedconversions" "github.com/gorilla/mux" "gocloud.dev/blob" + "hg.lukegb.com/lukegb/depot/web/fup/fuphttp/fngen" "hg.lukegb.com/lukegb/depot/web/fup/hashfs" ) @@ -40,6 +41,9 @@ type Config struct { // Set one of these, but not both. StorageURL string StorageBackend *blob.Bucket + + // FilenameGenerator returns a new filename based on the provided prefix and extension. + FilenameGenerator fngen.FilenameGenerator } type Application struct { @@ -49,6 +53,8 @@ type Application struct { redirectToBlobstore bool redirectExpiry time.Duration + + filenameGenerator fngen.FilenameGenerator } func (a *Application) Handler() http.Handler { @@ -109,10 +115,14 @@ func New(ctx context.Context, cfg *Config) (*Application, error) { a := &Application{ redirectToBlobstore: cfg.RedirectToBlobstore, redirectExpiry: cfg.RedirectExpiry, + filenameGenerator: cfg.FilenameGenerator, } if a.redirectExpiry == 0 { a.redirectExpiry = defaultRedirectExpiry } + if a.filenameGenerator == nil { + a.filenameGenerator = fngen.PetnameGenerator + } bkt := cfg.StorageBackend if bkt == nil {