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)