From 2c1342a20e2c690781447e1fe79a447ec2b0ce50 Mon Sep 17 00:00:00 2001
From: CronyAkatsuki
Date: Thu, 21 Dec 2023 12:08:07 +0100
Subject: [PATCH] File upload form
This one for you tulg.
---
main.go | 7 ++++++-
public/views/index.html | 8 ++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/main.go b/main.go
index 7d85a79..c525ab3 100644
--- a/main.go
+++ b/main.go
@@ -183,5 +183,10 @@ func Upload(c echo.Context) error {
fileUrl := c.Request().Host + "/files/" + file.Filename + "\n"
- return c.String(http.StatusOK, fileUrl)
+ UserAgent := c.Request().UserAgent()
+
+ if regexp.MatchString("^curl/.*", UserAgent); err != nil {
+ return c.String(http.StatusOK, fileUrl)
+ }
+ return c.Redirect(http.StatusMovedPermanently, "/files/"+file.Filename)
}
diff --git a/public/views/index.html b/public/views/index.html
index 41ca7a6..4e9972b 100644
--- a/public/views/index.html
+++ b/public/views/index.html
@@ -22,6 +22,14 @@
curl -F "file=@/path/to/file" "{{.Host}}"
+
+ Or for Tulg on a windows pc ;)
+
+
+
+
To delete a file using curl:
curl "{{.Host}}/delete/file_name"