partage

File upload system
git clone git://git.z3bra.org/partage.git
Log | Files | Refs | README | LICENSE

commit 4ce64b565483a1bfab64347f20b2c19758e5331f
parent 93b06c83c0a25c61796047d2e46db4dfc51db6aa
Author: Willy Goiffon <contact@z3bra.org>
Date:   Wed, 10 Nov 2021 11:38:55 +0100

Add support for "expiry" form setting

Diffstat:
Mpartage.go | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/partage.go b/partage.go @@ -92,6 +92,10 @@ func writemeta(filename string, expiry int64) error { size := stat.Size() f.Close() + if expiry < 0 { + expiry = conf.expiry + } + meta := metadata{ Filename: filepath.Base(filename), Size: size, @@ -196,7 +200,11 @@ func uploaderPost(w http.ResponseWriter, r *http.Request) { return } - writemeta(tmp.Name(), conf.expiry) + expiry, err := strconv.Atoi(r.PostFormValue("expiry")) + if err != nil || expiry < 0 { + expiry = int(conf.expiry) + } + writemeta(tmp.Name(), int64(expiry)) link := conf.baseuri + conf.filectx + filepath.Base(tmp.Name()) links = append(links, link)