From 2624427b6ca45495edb145e69219351ecd9ad967 Mon Sep 17 00:00:00 2001 From: ZizzyDizzyMC Date: Tue, 9 Feb 2021 23:07:18 -0500 Subject: [PATCH] Update upload.go --- upload.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/upload.go b/upload.go index a8c63af..b5e5a83 100644 --- a/upload.go +++ b/upload.go @@ -61,7 +61,6 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) { uploadHeaderProcess(r, &upReq) contentType := r.Header.Get("Content-Type") - if strings.HasPrefix(contentType, "multipart/form-data") { file, headers, err := r.FormFile("file") if err != nil { @@ -95,7 +94,7 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) { if r.PostFormValue("randomize") == "true" { upReq.randomBarename = true } - + upReq.srcIp = r.Header.Get("X-Forwarded-For") upload, err := processUpload(upReq) if strings.EqualFold("application/json", r.Header.Get("Accept")) { @@ -130,6 +129,7 @@ func uploadPutHandler(c web.C, w http.ResponseWriter, r *http.Request) { defer r.Body.Close() upReq.filename = c.URLParams["name"] upReq.src = http.MaxBytesReader(w, r.Body, Config.maxSize) + upReq.srcIp = r.Header.Get("X-Forwarded-For") upload, err := processUpload(upReq) if strings.EqualFold("application/json", r.Header.Get("Accept")) { @@ -201,6 +201,7 @@ func uploadRemote(c web.C, w http.ResponseWriter, r *http.Request) { upReq.accessKey = r.FormValue(accessKeyParamName) upReq.randomBarename = r.FormValue("randomize") == "yes" upReq.expiry = parseExpiry(r.FormValue("expiry")) + upReq.srcIp = r.Header.Get("X-Forwarded-For") upload, err := processUpload(upReq) if strings.EqualFold("application/json", r.Header.Get("Accept")) { @@ -233,7 +234,6 @@ func uploadHeaderProcess(r *http.Request, upReq *UploadRequest) { upReq.deleteKey = r.Header.Get("Linx-Delete-Key") upReq.accessKey = r.Header.Get(accessKeyHeaderName) - upReq.srcIp = r.Header.get("X-Forwarded-For") // Get seconds until expiry. Non-integer responses never expire. expStr := r.Header.Get("Linx-Expiry") upReq.expiry = parseExpiry(expStr)