From f5048a09f18ac676c4c7843b824026509400a6ce Mon Sep 17 00:00:00 2001 From: Simon Rieger Date: Mon, 1 Apr 2024 14:40:21 +0200 Subject: [PATCH] replace complete filename --- go/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/go/main.go b/go/main.go index f6ee66b..adc530f 100644 --- a/go/main.go +++ b/go/main.go @@ -126,9 +126,12 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { if forceName == "true" { filename = handler.Filename } else { + // Extrahiere nur die Dateiendung + fileExtension := filepath.Ext(handler.Filename) + // Zeitstempel zum Dateinamen hinzufügen timestamp := time.Now().Format("20060102-150405") - filename = fmt.Sprintf("%s-%s", timestamp, handler.Filename) + filename = fmt.Sprintf("%s%s", timestamp, fileExtension) } // Datei speichern