diff --git a/src/handlers.go b/src/handlers.go index 62bf2c5..7058b55 100644 --- a/src/handlers.go +++ b/src/handlers.go @@ -5,6 +5,7 @@ import ( "io" "os" "path/filepath" + "strconv" "time" "github.com/gin-gonic/gin" @@ -49,7 +50,14 @@ func uploadHandler(c *gin.Context) { return } - expiry := time.Now().Add(24 * time.Hour) + durationHours := 24 // default + if val := c.PostForm("duration"); val != "" { + fmt.Println("Duration provided:", val) + if parsed, err := strconv.Atoi(val); err == nil { + durationHours = parsed + } + } + expiry := time.Now().Add(time.Duration(durationHours) * time.Hour) record := FileRecord{ ID: id, diff --git a/src/main.go b/src/main.go index 96d90b7..a26c130 100644 --- a/src/main.go +++ b/src/main.go @@ -32,6 +32,7 @@ func main() { router := gin.Default() router.MaxMultipartMemory = 10 << 30 router.LoadHTMLGlob("templates/*") + router.StaticFS("/static", gin.Dir("./static", false)) // Public Routes router.GET("/", func(c *gin.Context) { c.HTML(200, "index.html", nil) }) diff --git a/static/logo.png b/static/logo.png new file mode 100644 index 0000000..4f85a0d Binary files /dev/null and b/static/logo.png differ diff --git a/templates/index.html b/templates/index.html index 11ff149..38a9ffd 100644 --- a/templates/index.html +++ b/templates/index.html @@ -91,8 +91,9 @@ -
- + +
+ Send.it logo

Send it

@@ -264,6 +265,8 @@ const fd = new FormData(); fd.append("file", file); fd.append("once", document.getElementById("once").checked ? "true" : "false"); + const hours = parseInt(document.getElementById("duration").value, 10); + fd.append("duration", hours * 3600); // convert hours to seconds const xhr = new XMLHttpRequest(); currentXhr = xhr;